|
Thanks Roger.. I wil try that...
|
|
|
|
|
I tried your solution and everything compiles and runs but my thread has no access to the class member variables. I initialize them in my class constructor but the thread function sees them as uninitialized.
Is there a way for my thread to access class member variables and functions.
Thanks!
|
|
|
|
|
You cant access nonstatic member from static function directly.
To solve this issue, create a static pointer to same class like
static CYourClass *thisClass; and assign this pointer to the static pointer, then user thisClass pointer in your thread. and aceess variable & functions using thisClass->fun() or thisCLass->varibel
|
|
|
|
|
I am not sure I completely understand your solution. Can you explain it a bit further?
Thanks.
|
|
|
|
|
I tried what you suggested and I got the following error:
CTCPServer::ListenThread': function call missing argument list; use '&CTCPServer::ListenThread' to create a pointer to member
Is there anyway to resolve this? If you need to see the code please let me know.. I didn't want to post it unnecessarily.
Thanks for your help.
|
|
|
|
|
The scenario is this:
In a 16 bit application A.app I am calling a 32 bit dll B.dll with a method exposed "DisplayDialog(HWND hWnd)".
DisplayDialog is called through the following sequence:
hDD = LoadLibraryEx32W(B.dll);
hDisplayDialog = (DISPLAYPPROC)GetProcAddress32W(hDD, "DisplayDialog");
CallProcEx32W(1, 1, hDisplayDialog, hWnd);
The resource for the dialog which I want to diaplay is in a 2nd 32 bit dll
C.dll. I am loading C.dll in B.dll using
hInstance = LoadLibrary(C.dll).
Then to display the dialog I am using this code in B.dll:
hDlg = CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_SOME_DIALOG), hWnd, (DLGPROC)SomeDlgProc, NULL);
ShowWindow(hDlg , SW_SHOWNORMAL);
SomeDlgProc is defined in B.dll.
hDlg is comming out as NULL.
GetLastError following the function call is returning 0.
Please advice what is going wrong.
Regards,
The scenario is this:
In a 16 bit application A.app I am calling a 32 bit dll B.dll with a method exposed "DisplayDialog(HWND hWnd)".
DisplayDialog is called through the following sequence:
hDD = LoadLibraryEx32W(B.dll);
hDisplayDialog = (DISPLAYPPROC)GetProcAddress32W(hDD, "DisplayDialog");
CallProcEx32W(1, 1, hDisplayDialog, hWnd);
The resource for the dialog which I want to diaplay is in a 2nd 32 bit dll
C.dll. I am loading C.dll in B.dll using
hInstance = LoadLibrary(C.dll).
Then to display the dialog I am using this code in B.dll:
hDlg = CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_SOME_DIALOG), hWnd, (DLGPROC)SomeDlgProc, NULL);
ShowWindow(hDlg , SW_SHOWNORMAL);
SomeDlgProc is defined in B.dll.
hDlg is comming out as NULL.
GetLastError following the function call is returning 0.
Please advice what is going wrong.
Regards,
|
|
|
|
|
Background
my MFC application developed on VS7.1, wrapped in InstallShield.
Users with Win2000 cannot run new project element.
(also installed SP4, .NetFramework and sometimes VS6)
Users with XP - no problems
Users with Win2000 and VS7 - no problem.
InstallShield delivers Mfc71.dll, mfc71u.dll, msvcp71.dll, msvcr71.dll, msvcrt.dll
New element is some windows hooking code.
I cannot use debug on VS7 becuase this fixes the problem.
I've tried Installshield dynamic scanning but i couldn't see what was missing.
The hooking code only includes stdafx.
Whats the easiest way to find the problem without adding loads of Message Boxes? I'm just toooo lazy for that
JBW
You can please some of the people all of the time and all of the people some of the time but not all of the people all of the time.
|
|
|
|
|
Use Process Explorer from SysInternals to see what modules are loaded while your program is running. One of those is probably missing from Windows 2000. Otherwise, perhaps you used an API that does not exist on Windows 2000.
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
Process explorer did show that for some reason Kernel32.dll is missing from my apps runtime on the problem machine. I don't get any system messages to warn me of an error though. I've tried statically linking my kernel32.lib but that doesn't work. It feels like some dll versioning problem but I don't really know so I'll have to keep looking.
You can please some of the people all of the time and all of the people some of the time but not all of the people all of the time.
|
|
|
|
|
I have reconsidered all my functions and I cannot see that I've used any functions that are XP only. I cannot find any articles to support my feelings that the kernel32.dll or other dlls are out of date. Furthermore, I cannot find any other developers, via google searching, who seem to have had this same problem where customers using win2000 with VS7 installed have no problem but customers without do.
Can anyone point me in a research direction?
You can please some of the people all of the time and all of the people some of the time but not all of the people all of the time.
|
|
|
|
|
I am currently developing a MFC dialog based application and i need a function----- void Pause(int time) such that Pause(3); will stop a loop(or rather the whole application) for 3 seconds...Pause(n) will stop a loop for n seconds..etc. What is the easiest way to write such a function(preferebly without #including any libraries) ? I have been experimenting with some of the syntax without much success...Can some kind soul please put me out of my misery and tell me how to do it ?
Thanks
|
|
|
|
|
|
|
|
What I do is set up a timer to interupt every second, and then count the interupts. When you have got to your required count, you can the go off and do the functionality that you want to do
Mike
|
|
|
|
|
WM_TIMER
This is a very easy thing to use, but is not 100% accurate.
You will need SetTimer and KillTimer
|
|
|
|
|
How can I achieve, that "Enter" works on a certain Button ? I´d like to change this during program. Sometimes Button "A" should work on ENTER, sometimes another one.
|
|
|
|
|
If you have a dialog-based application, you could set the default button with CDialog::SetDefID( UINT nID ) where nID is the ID of the new default button.
Hope this helps
--
Roger
It's supposed to be hard, otherwise anybody could do it!
|
|
|
|
|
Thanks, that works fine !
|
|
|
|
|
I'm writing a small app that has a number of classes in it. I would like to save the data to a single binary file. I understand how to write the data to the file, but when is comes to reading it again I'm lost.
If the data classes are written to the file in random order, (I know, not a good practice) how do I retrieve the data I have written to the file?
Or is it better to have a file for each class?
If you could point me in the right direction your help would be greatly appreciated...
Thanks, mcb36
|
|
|
|
|
You have of course to load your data in the same order you saved it. Otherwise you will get into big troubles.
|
|
|
|
|
So if I save class "A", then class "B", then class "C", that is the order I need to read it back in. That I can do, but how to I know when to move from class "A" to class "B"? is there a way to check if not more instances have been saved of each class? And what if on instances of class "B" have been saved? How do I know what data is saved in the file until I read it?
Thanks, mcb36
|
|
|
|
|
You need to store the number of instances of all classes that are saved in your file. But in general, the way to save your data is much more cleaner than that. You should take a look at serialization articles on the MSDN. A good way of doing that is to let each object save and load itself. So, if the object is made of several objects, it will save and load these specific objects, each of those are responsible for saving and loading themselves.
But in summary, if you need to save several objects without knowing the exact number (stored in an array for example), then you can simply save, before saving them, the number of elements of that type.
|
|
|
|
|
You can do it by using a chunk file. (An old Mac-invention if my mind serves me right).
It works like this:
Every item in a chunk file consists of a header and a (binary) data block.
The header has a fixed length (a struct), containing a label and the length of the following data block.
So when you write it, fill in the fields in the header and write it to the chunk file. Then write the data block to the chunk file.
When you read the chunk file, first read the header. Then you will know:
1.
The identification of the data block. (I.e. the class name)
2.
The data length (of the following data block).
Now you can choose either to read the data block, or discard it and continue reading the next header.
I have been using chunk files a lot in my work because:
1.
Every item is marked so I know in advance what data I can expect.
2.
I can easily skip the kind of data I don't want to read back.
Maybe you can try one?
Kakan
-- modified at 8:53 Wednesday 8th February, 2006
I agree with Cedric Moonen, you should have a look at serialisation. But if you find it less usable for you, the have a look at chunk files.
|
|
|
|
|
Thanks Kakan,
That sounds perfect for what I need to do = )
And thanks Cedric for your help = )
Thanks, mcb36
|
|
|
|