菜鸟求教:有关SDK创建对话框!
我用sdk创建了一个对话框,可是论怎样都收不到关闭窗口的消息,而且窗口没有标题、也不能移动,由此可以判断肯定是消息处理方面除了问题!我是新手,望指点!
程序如下:
#include <windows.h>
#include "resource.h"
static TCHAR szAppName[]="Test";
INT_PTR CALLBACK DiagFunc(HWND ,UINT ,WPARAM ,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
HWND hwnd;
MSG msg;
hwnd=CreateDialog(hInstance,szAppName,NULL,DiagFunc);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while (GetMessage(&msg,hwnd,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam ;
}
INT_PTR CALLBACK DiagFunc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_INITDIALOG:
MessageBox(hwnd,"OK!",szAppName,0);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,message,wParam,lParam);
}