LRESULT CALLBACK MessageWinProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)//用于处理消息窗口接收到的消息
{
switch(uMsg)
{
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_GRAPHNOTIFY:
//Dothings
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
BOOL InitMessageWindow()
{
HINSTANCE hInstance = NULL;
hInstance = GetModuleHandle(NULL);
if (hInstance == NULL)
{
return FALSE;
}
WNDCLASS wndcls;
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
wndcls.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndcls.hCursor=LoadCursor(NULL,IDC_CROSS);
wndcls.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndcls.hInstance=hInstance;
wndcls.lpfnWndProc=MessageWinProc;
wndcls.lpszClassName = L"Message Window";
wndcls.lpszMenuName=NULL;
wndcls.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wndcls);
m_hwnd = CreateWindowEx(0,L"Message Window",L"Message Window",0,0,0,0,0,HWND_MESSAGE,0,hInstance,0);
if (m_hwnd == NULL)
{
return FALSE;
}
return TRUE;
}
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)//用于处理消息窗口接收到的消息
{
switch(uMsg)
{
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_GRAPHNOTIFY:
//Dothings
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
BOOL InitMessageWindow()
{
HINSTANCE hInstance = NULL;
hInstance = GetModuleHandle(NULL);
if (hInstance == NULL)
{
return FALSE;
}
WNDCLASS wndcls;
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
wndcls.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndcls.hCursor=LoadCursor(NULL,IDC_CROSS);
wndcls.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndcls.hInstance=hInstance;
wndcls.lpfnWndProc=MessageWinProc;
wndcls.lpszClassName = L"Message Window";
wndcls.lpszMenuName=NULL;
wndcls.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wndcls);
m_hwnd = CreateWindowEx(0,L"Message Window",L"Message Window",0,0,0,0,0,HWND_MESSAGE,0,hInstance,0);
if (m_hwnd == NULL)
{
return FALSE;
}
return TRUE;
}