Code hint shortcut keys under vs2010: CTRL + J
Step
Window class Assignment (12 parameters)
Register window class
Create window
Message loops
#include <Windows.h>#include<tchar.h>LRESULT CALLBACK WindowProc (HWND hwnd, UINT umsg, WPARAM WPARAM, LPARAM LPARAM);intWINAPI WinMain (hinstance hinstance, hinstance hprevinstance, LPSTR lpCmdLine,intnShowCmd) { ConstTCHAR pclassname[] = _t ("Mywindow"); Wndclassex Wcex; Wcex.cbsize=sizeof(Wndclassex); Wcex.cbclsextra=0; Wcex.cbwndextra=0; Wcex.hbrbackground=(Hbrush):: Getstockobject (White_brush); Wcex.hcursor=:: LoadCursor (NULL, Idc_arrow); Wcex.hicon=:: LoadIcon (NULL, idi_application); WCEX.HICONSM=:: LoadIcon (NULL, idi_application); Wcex.hinstance=hinstance; Wcex.lpfnwndproc=WindowProc; Wcex.lpszclassname=Pclassname; Wcex.lpszmenuname=NULL; Wcex.style= Cs_hredraw |Cs_vredraw; BOOL BRet=:: RegisterClassEx (&Wcex); if(!BRet) {MessageBox (NULL, _t ("Tips"), _t ("failed to register window class"), MB_OK); returnFALSE; } HWND hwnd=:: CreateWindowEx (0, Pclassname, _t ("Windemo"), ws_visible|Ws_overlappedwindow, Cw_usedefault, Cw_usedefault, Cw_usedefault, Cw_usedefault, NULL, NULL, HINSTANCE, NULL); if(NULL = =hWnd) {MessageBox (NULL, _t ("Tips"), _t ("failed to create window! "), MB_OK); returnFALSE; }:: ShowWindow (HWnd, sw_show); :: UpdateWindow (HWND); MSG msg; while(GetMessage (&msg, NULL,0,0) {:: TranslateMessage (&msg); ::D Ispatchmessage (&msg); } returnTRUE;} LRESULT CALLBACK WindowProc (HWND hwnd, UINT umsg, WPARAM WPARAM, LPARAM LPARAM) {Switch(umsg) { Casewm_close:::D Estroywindow (HWND); return 0; CaseWm_destroy:::P ostquitmessage (0); return 0; default: Break; } return::D efwindowproc (Hwnd,umsg,wparam,lparam);}