|
Hello
I am using Combobox, and I have to manage quite big amount of data, If I do it with if sentence to assing the values, the program takes an excessive time.
The time it is taken when the event OnselChange is used (because of the amout of if used). This can be avoided in MFC by using Set/GetItemData, Is there any alternative to this with the CLI??
Thanks in advance
|
|
|
|
|
I am not a MFC programmer but the .NET Framework uses data binding to populate such controls.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
The items collection in the combobox is a collection of type object
As far as I know you can put any object in there and it will call ToString() on the object to get the label for the item.
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
|
Ok I did it,
I create the class
ref class MyDatas: public System::Object<br />
{<br />
String^ Name;<br />
double Value1, Value2;<br />
<br />
public:<br />
MyDatas(String^ NameC,double Value1C,double Value2C)<br />
{<br />
Name = NameC;<br />
Value1 = Value1C;<br />
Value2 = Value2C;<br />
}<br />
public:<br />
virtual String^ ToString () override<br />
{<br />
return Name;<br />
}<br />
<br />
};<br />
and I add the items to the comboBox like,
<br />
this->cBMyDatas->Items->AddRange(gcnew cli::array< System::Object^ >(4)<br />
{<br />
gcnew MyDatas("Data1",1,1),<br />
gcnew MyDatas("Data2",2,2),<br />
gcnew MyDatas("Data3",3,3)<br />
});<br />
And to get the item selected I just have to make a cast
DataSel = (MyDatas^) cBMyDatas->SelectedItem::get();
Thanks
|
|
|
|
|
Hi,
I've got a bunch of dll libraries written in VB that I would like to use within C++ (I'm using C++ within VS .NET).
I've gone through the archives, but can't find anything that provides examples of how to incorporate and use the dll functions.
Does anyone have any pointers or examples?
Thanks in advance,
John.
|
|
|
|
|
You won't find examples because they are not needed. All DLLs created by VB (at least up to version 6) are COM/ActiveX objects.
|
|
|
|
|
Hi all,
First of all, I hope this is the right place to post this thread...
I have recently received code which I must re-compile, the only thing is that the code was compiled in VS 2003 .Net, and I'm trying to re-compile it in VS 2005. I'm receiving alot of errors, and I have no Idea how to fix them, could any one please help??!!??
Thanx in advance.
ERRORS:
Error 1 error LNK2001: unresolved external symbol "?.cctor@@$$FYMXXZ" (?.cctor@@$$FYMXXZ) Stdafx.obj
Error 2 error LNK2001: unresolved external symbol "?.cctor@@$$FYMXXZ" (?.cctor@@$$FYMXXZ) AssemblyInfo.obj
Error 3 error LNK2001: unresolved external symbol "?.cctor@@$$FYMXXZ" (?.cctor@@$$FYMXXZ) AssemblyInfo.obj
Error 4 error LNK2001: unresolved external symbol "?.cctor@@$$FYMXXZ" (?.cctor@@$$FYMXXZ) Gdi.obj
Error 5 error LNK2001: unresolved external symbol "?.cctor@@$$FYMXXZ" (?.cctor@@$$FYMXXZ) Gdi.obj
Error 6 fatal error LNK1120: 1 unresolved externals c:\ID Print Source\IDCardPrint 2005-11-22\Native\bin\Release\Native.dll 1
Error 7 fatal error C1189: #error : Please use the /MD switch for _AFXDLL builds C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\include\afxver_.h 77
Error 9 'Could not load file or assembly 'Syncfusion.Core' or one of its dependencies. Invalid pointer (Exception from HRESULT: 0x80004003 (E_POINTER))' C:\ID Print Source\IDCardPrint 2005-11-22\IDDesign\LC IDDesign
Error 11 'Could not load file or assembly 'Syncfusion.Core' or one of its dependencies. Invalid pointer (Exception from HRESULT: 0x80004003 (E_POINTER))' C:\ID Print Source\IDCardPrint 2005-11-22\IDDesignApp\LC IDDesignApp
The only programmers that are better than C programmers are those who code in 1's and 0's.....
 Programm3r
|
|
|
|
|
Hello,
I wrote a native C++ dll which contains a class to hook windows messages.
As the callback function, I send a function pointer to my callback which is inside of my dll, but outside of the class.
I want a new instance of the function to be created for each instance of the class.
However, I can't declare my callback as non-static.
If I move my callback inside the class, and remove the static keyword I get a compile error saying:
"error C2440: 'type cast' : cannot convert from 'overloaded-function' to 'HOOKPROC'".
What can I do?
Any workarounds?
Thanks in advance,
Shy.
|
|
|
|
|
A callback that the operating sytem calls must be static.
There is only one instance of a function, whether the function is static or not. The only difference between a static and non-static member function is the this pointer.
|
|
|
|
|
With that said, how can I workaround this issue?
I need my callback to use instance variables, but of course it's not possible as they have to be static also.
If I use static variables it won't be any good to me...
Help...??
|
|
|
|
|
You did not state clearly whether this is a system-wide hook. Is it, or is it a thread-specific hook?
|
|
|
|
|
System-wide...
What's the difference when it comes to the static callback?
|
|
|
|
|
I won't waste my time trying to help you further.
|
|
|
|
|
|
Is it a callback that doesn't have a userdata parameter of some kind? Generally you can pass
an instance reference/pointer to methods that use a callback which will be passed to the callback.
In the callback it is cast to the proper type and used to access members. If it's your own
callback scheme then it should be easy to add a parameter.
|
|
|
|
|
Mark Salsbery wrote: Generally you can pass an instance reference/pointer to methods that use a callback which will be passed to the callback.
In the callback it is cast to the proper type and used to access members.
I'm not sure I understand...
Could you please rephrase it...?
Mark Salsbery wrote: If it's your own callback scheme then it should be easy to add a parameter.
It's not my callback scheme...
I use SetWindowsHookEx(), thus I'm forced to use the following signature:
static LRESULT CALLBACK MsgCallback(UINT nCode, WPARAM wParam, LPARAM lParam)<br />
Again, I'm not really sure what you meant.
I'll point out again that I'm writing a native C++ dll.
|
|
|
|
|
shyagam wrote: I'm not sure I understand...
Could you please rephrase it...?
I was referring to callbacks like the one used with EnumChildWindows() where there's a parameter
(app-defined) that you can pass to EnumChildWindows() which will be passed to the callback
fuction. You can pass an object pointer as this parameter and retrieve it in the static callback
and use it to access members of the object class.
With SetWindowsHookEx() you don't have this available. You're going to need an object reference
or pointer in the callback to get at any of the object class' non-static members. You could
store this pointer/reference somewhere - global variable, static member variable. Without it
you only have access to static members, as you know.
|
|
|
|
|
Thanks for the quick reply...
Mark Salsbery wrote: You could store this pointer/reference somewhere - global variable, static member variable.
I was thinking of holding a static list to all class instances.
Each constructor call would add the this pointer to the list.
The class would have an inner callback function.
The callback sent to SetWindowsHookEx() would then run a loop and call the inner callback inside each of the list's elements.
Do you see any potential flows in this?
|
|
|
|
|
Sounds like a plan Don't forget to thread-protect access to that list
|
|
|
|
|
Mark Salsbery wrote: Don't forget to thread-protect access to that list
Absolutly right... I'll keep that in mind!
Thanks again!
|
|
|
|
|
Using VS2005, if I was to run NOTEPAD.EXE from within an application - how would this be achieved ?
Pete
|
|
|
|
|
Can anyone tell me how I make an application run like a service(to start with windows,do not have a bar in the tool box like whe you enter My Computer) please
|
|
|
|
|
Is this a Turbo C++ or a native C++ question? If yes, you are in the wrong forum.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
How do you make an app to like a windows app(the blue title bar) I've tried to find over the internet but no luck:
|
|
|
|