# Include <windows. h> <br/> lresult callback wndproc (hwnd, uint, wparam, lparam); <br/> int winapi winmain (<br/> hinstance, <br/> hinstance hprevinstance, <br/> lpstr lpcmdline, <br/> int ncmdshow) <br/>{< br/> hwnd; <br/> wndclass; <br/> static tchar szappname [] = text ("hello"); <br/> MSG; <br/> bool Bret; </P> <p> wndclass. style = cs_hredraw | cs_vredraw; <br/> wndclass. lpfnwndpr OC = (wndproc) wndproc; <br/> wndclass. cbclsextra = 0; <br/> wndclass. cbwndextra = 0; <br/> wndclass. hinstance = hinstance; <br/> wndclass. hicon = loadicon (null, idi_application); <br/> wndclass. hcursor = loadcursor (null, idc_arrow); <br/> wndclass. hbrbackground = (hbrush) getstockobject (white_brush); <br/> wndclass. lpszmenuname = NULL; <br/> wndclass. lpszclassname = szappname; </P> <p> If (! Registerclass (& wndclass) <br/> return 0; </P> <p> hwnd = createwindow (szappname, <br/> text ("hello "), <br/> ws_overlappedwindow, <br/> 0, <br/> 0, <br/> 800, <br/> 600, <br/> null, <br/> null, <br/> hinstance, <br/> null); </P> <p> If (! Hwnd) <br/> return 0; </P> <p> showwindow (hwnd, ncmdshow); <br/> updatewindow (hwnd ); </P> <p> Bret = true; <br/> while (BRET) <br/> {<br/> Bret = getmessage (& MSG, null, 0, 0); <br/> If (Bret =-1) <br/> return 0; // error <br/> If (BRET) <br/>{< br/> translatemessage (& MSG); <br/> dispatchmessage (& MSG ); <br/>}< br/> return MSG. wparam; <br/>}< br/> lresult callback wndproc (hwnd, uint MSG, wparam, lparam) <br/>{< br/> paintstruct pS; <br/> HDC; <br/> rectrect; <br/> static hbrush; <br/> static byte red, green, blue; <br/> static DWORD color; </P> <p> switch (MSG) <br/> {<br/> case wm_create: <br/> color = 0; <br/> settimer (hwnd, 1, 10, null); <br/> break; <br/> case wm_timer: <br/> color = color + 1; <br/> If (color> 0x00ffffff) <br/> color = 0; <br/> invalidaterect (hwnd, null, false); <br/> break; <br/> case wm_paint: <br/> HDC = beginpaint (hwnd, & PS); <br/> getclientrect (hwnd, & rect ); <br/> hbrush = createsolidbrush (color); <br/> fillrect (HDC, & rect, hbrush); <br/> endpaint (hwnd, & PS ); <br/> deleteobject (hbrush); <br/> break; <br/> case wm_close: <br/> destroywindow (hwnd); <br/> break; <br/> case wm_destroy: <br/> killtimer (hwnd, 1); <br/> postquitmessage (0); <br/> break; <br/> default: <br/> return defwindowproc (hwnd, MSG, wparam, lparam); <br/>}< br/> return 0; <br/>}< br/>