# Include < Windows. h >
//Window Process Declaration
Lresult callback wndproc (hwnd, uint, wparam, lparam );
Int _ Stdcall winmain (hinstance, hinstance hprevinstance, lpstr lpcmdline, Int Ncmdshow)
{
Const Char * Szwindowname = " First Windows ApplicationProgram " ; // Window title
Const Char * Szclassname = " Windowclass " ; // Window class name
// Create a wndclassex struct variable and set the member value for it.
Wndclassex wndclass;
Wndclass. cbsize = Sizeof (Wndclassex ); // Structure Size
Wndclass. Style = Cs_hredraw | Cs_vredraw; // Horizontal and vertical
Wndclass. lpfnwndproc = (Wndproc) wndproc; // Window Process
Wndclass. cbclsextra = 0 ; // No additional class memory
Wndclass. cbwndextra = 0 ; // No additional window memory
Wndclass. hinstance = Hinstance; // Instance handle
Wndclass. hicon = Loadicon (null, idi_application ); // Program icon
Wndclass. hcursor = Loadcursor (null, idc_cross ); // Mouse Style
Wndclass. hbrbackground = (Hbrush): getstockobject (white_brush ); // White Background
Wndclass. lpszmenuname = NULL; // No menu name
Wndclass. lpszclassname = Szclassname; // Window class name
Wndclass. hiconsm = NULL; // No small icon for the class
//Register the wndclassex struct
: Registerclassex (&Wndclass );
// Create Main Window
Hwnd = : Createmediawex (
0 , // Dwexstyle, extended Style
Szclassname, // Lpclassname, Class Name
Szwindowname, // Lpwindowname, title
Ws_overlappedwindow, // Dwstyle, window style
Cw_usedefault, // X, initial X coordinate
Cw_usedefault, // Y, initial y coordinate
Cw_usedefault, // Nwidth, width
Cw_usedefault, // Nheight, height
Null, // Hwndparent, parent window handle
Null, // Hmenu, menu handle
Hinstance, // Hinstance, program instance handle
Null ); // Lpparam, user data
If (Hwnd = Null)
{
: MessageBox (null, " An error occurred while creating the window! " , " Error " , Mb_ OK );
Return False;
}
//Display window
: Showwindow (hwnd, ncmdshow );
//Refresh window
: Updatewindow (hwnd );
// message loop
MSG;
while (: getmessage ( & MSG, null, 0 , 0 ))
{< BR >:: translatemessage ( & MSG);
:: dispatchmessage ( & MSG);
}
ReturnMSG. wparam;
}
//Window Process Functions
Lresult callback wndproc (hwnd, uint message, wparam, lparam)
{
Const Char*Szhello= "Hello World";
Switch (Message)
{
// Redraw window
Case Wm_paint:
HDC;
Paintstruct pS;
HDC = : Beginpaint (hwnd, & PS );
: Textout (HDC, 10 , 10 , Szhello, strlen (szhello ));
: Endpaint (hwnd, & PS );
Break ;
// Destruction window
Case Wm_destroy:
: Postquitmessage ( 0 );
Break ;
}
//Hand over to the system for default Processing
Return: Defwindowproc (hwnd, message, wparam, lparam );
}