我编了一个简单的windows程序,只是创建了一个窗口,编译连接都没有错误。
但运行没结果,即没有出现窗口。
我用messagebox检查了,觉得可能是注册失败,请问该怎么处理。
#include <windows.h> LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevinst, LPSTR lpszCmdLine, int nCmdShow) { HWND hwnd ; MSG Msg; WNDCLASS wndclass; char lpszClassName[]="windowsL"; char lpszTitle[]="My_Windows"; wndclass.style=0; wndclass.lpfnWndProc=WndProc; wndclass.cbClsExtra=0; wndclass.hInstance=hInstance; wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION); wndclass.hCursor=LoadCursor(NULL,IDC_ARROW); wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH); wndclass.lpszMenuName=NULL; wndclass.lpszClassName=lpszClassName; if(!RegisterClass(&wndclass)) { MessageBox(NULL,"mistake","check",MB_OK|MB_ICONEXCLAMATION);
return FALSE; } hwnd=CreateWindow(lpszClassName, lpszTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); ShowWindow(hwnd,nCmdShow); UpdateWindow(hwnd); while(GetMessage(&Msg,NULL,0,0)) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; } LRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_DESTROY: PostQuitMessage(0); default: return DefWindowProc(hwnd,message,wParam,lParam); } return(0); }