المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Visual C++ Express receiving a custom message



C++ Programming
07-24-2011, 05:40 AM
I am totally new to C++, this is the first thing I've tried to do.
I have a simple program (A) which I want to receive a message from and send a message to another app (B).
I can send messages from A to B fine but if I do then A longer sees the message sent from B, although B gets 0 as the return from the message it sends to A.
I can receive a message (Message number AuMessage obtained using RegisterWindowMessageA) once from B but the message isn't received by A a second time if I send a message to B. If I never send a message to B I can keep receiving the messages in A.

Obviously I'm doingsomething wrong. Every reference seems to tell me to use something like this

BEGIN_MESSAGE_MAP(szWindowClass, CMyParentWndClass) //{{AFX_MSG_MAP(CWordPadApp) //AFX_MSG_MAP // ON_MESSAGE(AuMessage,HandleAuCommand); //}}AFX_MSG_MAPEND_MESSAGE_MAP()
but I cannot see how to find CMyParentWndClass, so I have added code to WinProc like this

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){ int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; //added this if clause if (message == AuMessage ) {msgin = 7;some flag I intend to use return 76;//any number for tests just so the sending app sees a reply } switch (message)...
I couldn't add a new case because using a variable (AuMessage ) gives a compilation error.

How should I handle receiving and sending custom messages? Or can anyone supply a link where I can find the correct approach?