vc sdk编程遇到的小问题。。单步调试到注册类的时候弹出。。
#include <windows.h>#include <stdio.h>LRESULT CALLBACK WindowProc( HWND hwnd, // handle to window UINT uMsg, // message identifier WPARAM wParam, // first message parameter LPARAM lParam // second message parameter );int WINAPI WinMain( HINSTANCE hInstance, // handle to current instance HINSTANCE hPrevInstance, // handle to previous instance LPSTR lpCmdLine, // command line int nCmdShow // show state ){ WNDCLASS wndcls; wndcls.cbClsExtra=0; wndcls.cbWndExtra=0; wndcls.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH); wndcls.hCursor=LoadCursor(NULL,IDC_IBEAM); wndcls.hIcon=LoadIcon(NULL,IDI_EXCLAMATION); wndcls.hInstance=hInstance; wndcls.lpfnWndProc=WindowProc; wndcls.lpszClassName=TEXT("tom"); wndcls.style=CS_HREDRAW|CS_VREDRAW; RegisterClass(&wndcls); HWND hWnd; hWnd=CreateWindow(TEXT("tom"),"MyFirstWin32SDKProgram",WS_OVERLAPPED,200,153,600,400,NULL,NULL,hInstance,NULL); ShowWindow(hWnd,SW_SHOWNORMAL); UpdateWindow(hWnd); MSG msg; while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0;}LRESULT CALLBACK WindowProc( HWND hwnd, // handle to window UINT uMsg, // message identifier WPARAM wParam, // first message parameter LPARAM lParam // second message parameter ){ HDC hDC; PAINTSTRUCT ps; switch(uMsg) { case WM_PAINT: hDC=BeginPaint(hwnd,&ps); TextOut(hDC,0,0,"Hello WIN32 SDK",strlen("Hello WIN32 SDK")); EndPaint(hwnd,&ps); break; case WM_CHAR: char szChar[20]; sprintf(szChar,"The char you entered is %c",wParam); MessageBox(hwnd,"Hello WIN32 SDK","Message",0); break; case WM_LBUTTONDOWN: MessageBox(hwnd,"You've Clicked the LButton!","Message",MB_ABORTRETRYIGNORE); break; case WM_DESTROY: if(IDYES==MessageBox(hwnd,"Are you sure to quit?","Message",MB_OKCANCEL)) DestroyWindow(hwnd); break; case WM_QUIT: PostQuitMessage(0); break; default: DefWindowProc(hwnd,uMsg,wParam,lParam); } return 0; }
default: return DefWindowProc(hwnd,uMsg,wParam,lParam);