1 #defineWin32_lean_and_mean2#include <windows.h>3#include <windowsx.h>4#include <math.h>5 #defineWindow_class_name L "WINCLASS1"6 //window processing Functions7 LRESULT CALLBACK WindowProc (HWND hwnd,8 UINT msg,9 WPARAM WPARAM,Ten LPARAM Lpram) One { A paintstruct PS; - HDC hdc; - Switch(msg) the { - Casewm_create: - { - return 0; +} Break; - CaseWM_PAINT: + { AHDC = BeginPaint (hwnd, &PS); atEndPaint (hwnd, &PS); - return 0; -} Break; - default: Break; - } - returnDefWindowProc (hwnd, MSG, WParam, lpram); in } - voidGamemain () to { + return; - } the intWINAPI WinMain (hinstance hinstance, * hinstance hPrevInstance, $ LPSTR lpCmdLine,Panax Notoginseng intncmdshow) - { the //Defining window Classes + wndclassex Winclass; A HWND hwnd; the msg msg; + //populating a member of a window class -Winclass.cbsize =sizeof(wndclassex); $Winclass.style = Cs_dblclks | CS_OWNDC | Cs_hredraw |Cs_vredraw; $Winclass.lpfnwndproc = WindowProc;//window Message handler function -Winclass.cbclsextra =0; -Winclass.cbwndextra =0; theWinclass.hinstance =hinstance; -Winclass.hicon =LoadIcon (NULL, idi_application);WuyiWinclass.hcursor =loadcursor (NULL, idc_arrow); theWinclass.hbrbackground =(Hbrush) getstockobject (Black_brush); -Winclass.lpszmenuname =NULL; WuWinclass.lpszclassname = Window_class_name;//window class name -WINCLASS.HICONSM =LoadIcon (NULL, idi_application); About $ //Register window class - if(! RegisterClassEx (&winclass)) - { - return 0; A } + the //create a member of a window class - if(! (HWnd =CreateWindowEx (NULL, $ Window_class_name, theL"Hello World", theWs_overlappedwindow |ws_visible, the 0,0, the 640,480, - NULL, in NULL, the hinstance, the NULL ))) About { the return 0; the } the + //message Loops - while(true) the {Bayi if(PeekMessage (&msg, HWnd,0,0, Pm_remove)) the { the if(Msg.message = =wm_quit) - { - Break; the } theTranslateMessage (&msg); theDispatchMessage (&msg); the } - Gamemain (); the } the returnMsg.wparam; the}
Windows programming: The first Windows program