1.我用RegisterWinodowsMessage()注册了一个消息.
2.在WndProc中 处理我自己定义的消息,在编译的时候,就会出错.
如下:
//my message
static UINT MY_MESSAGE = RegisterWindowMessage("MY_MESSAGE");//operater my message
...WndProc(...){
...
case MY_MESSAGE://在这儿就出来了错误?
....break;
...}求各位大哥大姐,前辈高人,给点办法,我就要在SDK下的自定义消息的办法!!先跪谢了!!
2.在WndProc中 处理我自己定义的消息,在编译的时候,就会出错.
如下:
//my message
static UINT MY_MESSAGE = RegisterWindowMessage("MY_MESSAGE");//operater my message
...WndProc(...){
...
case MY_MESSAGE://在这儿就出来了错误?
....break;
...}求各位大哥大姐,前辈高人,给点办法,我就要在SDK下的自定义消息的办法!!先跪谢了!!
case WM_MYMESSAGE:
#include "resource.h"UINT g_uMyMsg;
UINT_PTR g_uTimer = 1000 ;// Window Procedure
BOOL CALLBACK DialogProc(HWND hDialog, UINT message, WPARAM wParam, LPARAM lParam)
{
if ( message == g_uMyMsg )
{
MessageBox(hDialog, "Recieved!", "My Message", MB_OK);
return TRUE;
} switch ( message )
{
case WM_INITDIALOG:
g_uTimer = SetTimer(hDialog, g_uTimer, 0, NULL);
break; case WM_TIMER:
{
if ( wParam == g_uTimer )
{
KillTimer(hDialog, g_uTimer);
g_uMyMsg = RegisterWindowMessage("MyTestMessage");
SendMessage(hDialog, g_uMyMsg, 0, 0);
}
}
break; return TRUE;
} return FALSE;
}int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
HWND dlgHwnd;
MSG msg; dlgHwnd = CreateDialog(hInstance,MAKEINTRESOURCE(IDD_DIALOG1),0,(DLGPROC)DialogProc); // Error Check
if(!dlgHwnd)
return EXIT_FAILURE; // Something really bad happened! ShowWindow(dlgHwnd, SW_SHOW);
UpdateWindow(dlgHwnd);
// Loop until the app is done
while(1)
{
// Get message(s) (for instance a key press) if there is any
if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
if(msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
// Do all the hardcore computational stuff here :)
} } DestroyWindow(dlgHwnd); // Destroys (frees) up our dialog box
return msg.wParam;
}
原来用RegisterWinodowsMessage注册的消息,只是一个动态的值.而在case处,只能用一个常量,所以就出现上面的错误了,多谢上面的几位的帮助.我后来,只好用 aspnetwuxueyou(aspnet) 类似的办法处理了,现在已经搞定了.真没办法!呵呵......哪现在就给分吧!!!