#include <windows.h>
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain1 (hinstance hInst, hinstance, LPSTR szcmd, int nshow)
{
Wndclass Wndclass;
TCHAR *classname = TEXT ("MyClass");
HWND hwnd;//used to record window handles
MSG msg;//defines a message structure that is used to store the retrieved message
Wndclass.cbclsextra = 0;
Wndclass.cbwndextra = 0;
Wndclass.hbrbackground = (hbrush) (Color_window + 1);
Wndclass.hcursor = LoadCursor (NULL, Idc_arrow);
Wndclass.hicon = LoadIcon (NULL, idi_application);
Wndclass.lpfnwndproc = WndProc;
Wndclass.lpszclassname = classname;//class name
Wndclass.lpszmenuname = null;//temporarily do not menu
Wndclass.style = Cs_vredraw | Cs_hredraw;
RegisterClass (&wndclass);//Registration window
#define CREATEWINDOWW (Lpclassname, Lpwindowname, Dwstyle, X, Y,\nwidth, nheight, hWndParent, HMenu, HINSTANCE, LpParam )
hwnd = CreateWindow (
classname/* window class */,
TEXT ("Hello"/* Window name */),
ws_overlappedwindow/* window type */,
cw_usedefault/* Default window position of the horizontal axis */,
cw_usedefault/* default window Position ordinate */,
500/* the width of the window */,
The 300/* window is high */,
null/* Parent window: No parent window, default is desktop */,
null/* No Menu */,
hinst/* Program Instance handle */,
NULL);
ShowWindow (hwnd, nshow);//Display window
UpdateWindow (HWND);//Refresh Window
while (GetMessage (&msg, NULL, 0, 0)//If message 0 is sent to the window, exit the Loop End program
{
TranslateMessage (&msg);//Translation
DispatchMessage (&msg);//Send the message to the window program that handles the message
}
return 0;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM WPARAM, LPARAM LPARAM)
{
Switch (message)
{
Case Wm_destroy:
PostQuitMessage (0);//Send an exit message to the program exit value 0
return 0;
Default
Return DefWindowProc (HWND, message, WParam, lparam);//Do not process yourself, handing over to the system
}
}
Early Windows Experience