[求助]一个简单的窗口问题
今天在做练习的时候,按照往常先创建一个窗口,但发现这个窗口虽然可以编译,但是运行后却对我的消息作不出任何反映,关都关不掉,可是我是按照往常的方法做的,检查了几遍也没觉出错,也许错误很简单,请大家帮我看看吧,谢谢...
#include<windows.h>
HWND hwnd;
MSG msg;
WNDCLASS wnd;
long CALLBACK winproc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE h,HINSTANCE preh,LPSTR str,int m)
{
wnd.hInstance=h;
wnd.lpfnWndProc=winproc;
wnd.lpszClassName="wnd";
wnd.hbrBackground=(HBRUSH)::GetStockObject(WHITE_BRUSH);
::RegisterClass(&wnd);
hwnd=::CreateWindow("wnd","window",WS_OVERLAPPEDWINDOW,50,50,640,480,NULL,NULL,h,NULL);
::ShowWindow(hwnd,SW_SHOWNORMAL);
::UpdateWindow(hwnd);
while(::GetMessage(&msg,NULL,0,0));
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
return msg.wParam;
}
long CALLBACK winproc(HWND hwnd,UINT message,WPARAM w,LPARAM l)
{
switch(message)
{
case WM_DESTROY:
::PostQuitMessage(0);
break;
default:
return ::DefWindowProc(hwnd,message,w,l);
}
return 0;
}
HWND hwnd;
MSG msg;
WNDCLASS wnd;
long CALLBACK winproc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE h,HINSTANCE preh,LPSTR str,int m)
{
wnd.hInstance=h;
wnd.lpfnWndProc=winproc;
wnd.lpszClassName="wnd";
wnd.hbrBackground=(HBRUSH)::GetStockObject(WHITE_BRUSH);
::RegisterClass(&wnd);
hwnd=::CreateWindow("wnd","window",WS_OVERLAPPEDWINDOW,50,50,640,480,NULL,NULL,h,NULL);
::ShowWindow(hwnd,SW_SHOWNORMAL);
::UpdateWindow(hwnd);
while(::GetMessage(&msg,NULL,0,0));
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
return msg.wParam;
}
long CALLBACK winproc(HWND hwnd,UINT message,WPARAM w,LPARAM l)
{
switch(message)
{
case WM_DESTROY:
::PostQuitMessage(0);
break;
default:
return ::DefWindowProc(hwnd,message,w,l);
}
return 0;
}