int Apientry _tWinMain (_in_ hinstance hinstance,
_in_opt_ hinstance hPrevInstance,
_in_ LPTSTR lpCmdLine,
_in_ int nCmdShow)
The 1._twinmain function is the entry point for the program
2.MyRegisterClass registers the window class by calling this function (setting window properties, styles, callback functions, etc.)
The specific function is as follows
ATOM MyRegisterClass (hinstance hinstance)//hinstance: Application Current instance{ //struct EX represents the premium version of the WNDCLASSEX structure for registering window classesWndclassex Wcex; Wcex.cbsize=sizeof(Wndclassex); Wcex.style= Cs_hredraw | Cs_vredraw;//styleWcex.lpfnwndproc = WndProc;//indicates the function callback function addressWcex.cbclsextra =0; Wcex.cbwndextra=0; Wcex.hinstance=hinstance; Wcex.hicon=LoadIcon (hinstance, Makeintresource (Idi_win32project1)); Wcex.hcursor=loadcursor (NULL, Idc_arrow); Wcex.hbrbackground= (Hbrush) (color_window+1); Wcex.lpszmenuname=Makeintresource (IDC_WIN32PROJECT1); Wcex.lpszclassname=Szwindowclass; WCEX.HICONSM=LoadIcon (Wcex.hinstance, Makeintresource (Idi_small)); returnRegisterClassEx (&Wcex);}
It calls RegisterClassEx to complete the registration and tells the system what the window was built to grow.
3.CreateWindow Create window
int ncmdshow)
Call CreateWindow by the function above
Parameter 1: Name of the window class
Parameter 2: The name of the window
Parameter 3: You can set the style of some windows
Parameter 8: Handle to parent window
Parameter 9: Handle to Menu
Parameter 10: Initialization of a message
HWnd = CreateWindow (Szwindowclass, L"hello", Ws_overlappedwindow, 500 , NULL, NULL, HINSTANCE, NULL);
With the first parameter, Szwindowclass--The name of the window class---> To tell the System what window to create
In vs2013, you can see in the string table file
4.ShowWindow (HWnd, ncmdshow); Display window
UpdateWindow (HWND);
5. Introduction to other functions
5.1 LoadString (HINSTANCE, Idc_win32project1, Szwindowclass, max_loadstring); To get a string by loadstring
5.2 Callback function: LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM WPARAM, LPARAM LPARAM)
Respond to various messages.
6 Other knowledge points
Window uses a message mechanism
Window Programming's WIN program framework