1#include <windows.h>2#include"resource.h"3 4LRESULT CALLBACK Mywndproc (HWND hwnd,//Handle to Window5UINT umsg,//message identifier6WPARAM WPARAM,//First message parameter7LPARAM LPARAM//Second message parameter8 );9 Ten intWINAPI WinMain (hinstance hinstance, hinstance hprevinstance, LPSTR lpCmdLine,intnshowcmd) One { A wndclass wnd; - HWND hwnd; - msg msg; theTCHAR szappname[ +];//define the application name -Wnd.style = Cs_hredraw | Cs_vredraw;//The horizontal or vertical change window is redrawn with Mywndproc's WM_PAINT message Association -Wnd.lpfnwndproc =Mywndproc; -Wnd.cbclsextra =0; +Wnd.cbwndextra =0; -Wnd.hicon =LoadIcon (NULL, idi_application); +Wnd.hcursor =loadcursor (NULL, idc_arrow); AWnd.hbrbackground =(Hbrush) getstockobject (White_brush); atWnd.lpszmenuname =NULL; -Wnd.lpszclassname ="Helloclass";//window class identifier, used in the first parameter of CreateWindow -Wnd.hinstance =hinstance; - if(! RegisterClass (&wnd)) - { -MessageBox (NULL, TEXT ("Unable to create window"), TEXT ("ERROR"), mb_ok|mb_iconerror); in return 0; - } to +LoadString (HInstance, Ids_appname, Szappname,sizeof(Szappname));//The loadstring function copies the resource to the program area cache -hwnd = CreateWindow ("Helloclass", Szappname, Ws_overlappedwindow, Cw_usedefault, Cw_usedefault, Cw_usedefault, cw_usedefault, NULL, NULL, HInstance, NULL);//The second argument is a window caption the ShowWindow (hwnd, nshowcmd); * while(GetMessage (&msg, NULL,0,0)) $ {Panax NotoginsengTranslateMessage (&msg); -DispatchMessage (&msg); the } + return 0; A } the + LRESULT CALLBACK Mywndproc (HWND hwnd, UINT umsg, WPARAM WPARAM, LPARAM LPARAM) - { $HDC hdc;//defining a device environment handle $Paintstruct PS;//Drawing Structures -Rect rect;//Rectangular Structure - Switch(umsg) the { - CaseWM_PAINT:Wuyi { theHDC = BeginPaint (hwnd, &PS); -GetClientRect (hwnd, &rect); WuDrawText (HDC, TEXT ("hello,world!"), -1, &rect, dt_singleline| dt_center|dt_vcenter); -EndPaint (hwnd, &PS); About } $ Break; - CaseWm_destroy: -PostQuitMessage (0); - return 0; A } + the returnDefWindowProc (hwnd, umsg, WParam, LParam); -}
int LoadString (hinstance hinstance , //Handle to resource module< strong> UINT uID , //Resource identifier LPTSTR lpbuffer , //resource buffer int Nbuffermax //size of buffer );