How can I create a custom windows message that passes any data to a different program.
I am messaging between a GUI-program and a server-program. My background is in *nix programming and I am a bit lost in the windows world.
Currently both programs are created by Visual Studio's wizard by chosing "MFC windowed application". Now I want an elegant way to communicate between the programs. Google gives me Cwnd->sendmessage + registering your own messages etc. However, I cannot pass a char pointer to a different program with standard custom messages (well, I can but the memory area is wrong, and the program segfaults). So, google again gives me sendmessage(WM_COPYDATA, hparam, lparam) which is marshalled. When googling marshalling... I ran into a wall.
I assume that marshalled messages (or their data) are passed into a shared memory area which is readable only by the sender and the receiver program (correct?). And by creating a custom message that has a pointer of marshalled data as lparam, I can pass any object to another program (correct?). How do I do this in practice? I tried the following:
pWin->SendMessage(pTargetWin, WM_CUSTOM_MESSAGE, pSourceWin, pData);
Above works if pData is integer. If pData is a pointer to object, I cannot use the object because of the missing marhsalling. I know that I can do a wrapper COPYDATASTRUCT wrapper to pData and change to WM_COPYDATA. Should I do that instead?
br, Juha