Window Programming's WIN program framework

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.