QBasicer
July 19th, 2006, 06:44 PM
I wrote a sender program that (correctly) finds the HWND of the remote program by registered class name. This is the code for the struct:
typedef struct{
char* msg;
char* title;
int flags;
}MSGBOX;
And the send code (excluding the search for the HWND):
HGLOBAL msgboxhandle = GlobalAlloc(0, sizeof(MSGBOX));
MSGBOX *foo;
foo = (MSGBOX*)GlobalLock(msgboxhandle);
foo->flags = MB_OK | MB_ICONINFORMATION;
foo->msg = "Testing";
foo->title = "Message Testing";
GlobalUnlock(msgboxhandle);
SendMessage(tWindow, WM_USER + 5, (WPARAM)NULL, (LPARAM)msgboxhandle);
GlobalFree(msgboxhandle);
I've tried a few things, including locally defining a MSGBOX on the stack and using &foo to send it (using both wParam and lParam, I'm not sure what the differences are).
And the receieving code:
case WM_USER + 5:
MSGBOX *in;
in = (MSGBOX*)GlobalLock((HGLOBAL)lParam);
MessageBox(hWnd, in->msg, "Incoming Message", MB_OK);
GlobalUnlock((HGLOBAL)lParam);
break;
It turns up blank every time on the receiving side.
Thanks.
typedef struct{
char* msg;
char* title;
int flags;
}MSGBOX;
And the send code (excluding the search for the HWND):
HGLOBAL msgboxhandle = GlobalAlloc(0, sizeof(MSGBOX));
MSGBOX *foo;
foo = (MSGBOX*)GlobalLock(msgboxhandle);
foo->flags = MB_OK | MB_ICONINFORMATION;
foo->msg = "Testing";
foo->title = "Message Testing";
GlobalUnlock(msgboxhandle);
SendMessage(tWindow, WM_USER + 5, (WPARAM)NULL, (LPARAM)msgboxhandle);
GlobalFree(msgboxhandle);
I've tried a few things, including locally defining a MSGBOX on the stack and using &foo to send it (using both wParam and lParam, I'm not sure what the differences are).
And the receieving code:
case WM_USER + 5:
MSGBOX *in;
in = (MSGBOX*)GlobalLock((HGLOBAL)lParam);
MessageBox(hWnd, in->msg, "Incoming Message", MB_OK);
GlobalUnlock((HGLOBAL)lParam);
break;
It turns up blank every time on the receiving side.
Thanks.