#include <windows.h>LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);intWINAPI WinMain (hinstance hinstance, hinstance hprevinstance, PSTR szCmdLine,inticmdshow) { StaticTCHAR szappname[] = TEXT ("Windowofc"); HWND hwnd;//form Handle VariablesMSG msg;//Message VariablesWndclass Wndclass;//window class Variables//Configuring the window class structureWndclass.style = Cs_hredraw |Cs_vredraw; Wndclass.lpfnwndproc=WndProc; Wndclass.cbclsextra=0; Wndclass.cbwndextra=0; Wndclass.hinstance=hinstance; Wndclass.hicon=LoadIcon (NULL, idi_application); Wndclass.hcursor=loadcursor (NULL, Idc_arrow); Wndclass.hbrbackground=(Hbrush) Color_window; Wndclass.lpszmenuname=NULL; Wndclass.lpszclassname=Szappname; //Register window class if(! RegisterClass (&wndclass)) {MessageBox (NULL, TEXT ("failed to register window Class! "), Szappname, Mb_iconerror); return 0; } hwnd=CreateWindow (Szappname, TEXT ("C language Calls Windows API created window"), Ws_overlappedwindow, Cw_usedefault, Cw_usedefault, Cw_usedefault, Cw_usedefault, NULL, NULL, HINSTANCE, NULL); ShowWindow (hwnd, icmdshow); UpdateWindow (HWND); while(GetMessage (&msg, NULL,0,0) {translatemessage (&msg); DispatchMessage (&msg); } returnMsg.wparam;};//Message handling methods, callback functions for Windows operating systemsLRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM WPARAM, LPARAM LPARAM) {HDC hdc; Paintstruct PS; Rect rect; Switch(message) { CaseWm_create:messagebox (NULL, TEXT ("the window is created! "), NULL, Mb_iconerror); return 0; CaseWM_PAINT:HDC= BeginPaint (hwnd, &PS); GetClientRect (hwnd,&rect); DrawText (hdc, TEXT ("Hello C windows"), -1, &rect, Dt_singleline | Dt_center |dt_vcenter); EndPaint (hwnd,&PS); return 0; CaseWm_destroy:postquitmessage (0); return 0; } returnDefWindowProc (hwnd, message, WParam, LParam);};
(C) window programs for the first Windows + API (