Window registration class structure and message structure

Source: Internet
Author: User

 This topic describes Windows API window registration and message structure.

 

WNDCLASSEX window registration class:

Struct prototype:

typedef struct WNDCLASSEX {    UINT cbSize;    UINT style;    WNDPROC lpfnWndProc;    int cbClsExtra;    int cbWndExtra;    HINSTANCE hInstance;    HICON hIcon;    HCURSOR hCursor;    HBRUSH hbrBackground;    LPCTSTR lpszMenuName;    LPCTSTR lpszClassName;    HICON hIconSm;  } WNDCLASSEX, *PWNDCLASSEX;

 

Parameters:

CbSize:

The size of WNDCLASSEX. We can use sizeof (WNDCLASSEX) to obtain accurate values.

Style:

The style of the window derived from this window class. You can use the "or" operator to combine several styles.

LpfnWndProc:

The pointer of the window processing function.

CbClsExtra:

Specify the number of additional bytes that follow the window class structure.

CbWndExtra:

Specify the number of additional bytes that follow the window example. If an application registers a dialog box CLASS with CLASS pseudoinstructions in the resource, it must be set to dlgw.wextra.

HInstance:

The case handle of this module.

HIcon:

The handle of the icon.

HCursor:

The handle of the cursor.

HbrBackground:

The background paint brush handle.

LpszMenuName:

Pointer to the menu.

LpszClassName:

Pointer to the class name.

HIconSm:

The small icon associated with the window class. If the value is NULL. Then, the icon in hCursor is converted to an appropriate small icon.

 

The most important member of WNDCLASSEX is lpfnWndProc. The prefix lpfn indicates that the member is a long pointer to the function. In Win32, because the memory mode is FLAT, there is no difference between near and far. Each window class must have a window process. When Windows sends messages belonging to a specific window to this window, the window class is responsible for processing all messages, for example, a keyboard message or a mouse message. Since the Window Process intelligently processes all the window message loops, you only need to add the message processing process to it.

 

The MSG message structure is as follows:

typedef struct tagMSG {     HWND hwnd;     UINT message;     WPARAM wParam;     LPARAM lParam;     DWORD time;     POINT pt;   } MSG, *PMSG;

  

Parameters:

Hwnd:

The handle to send the message to the window.

Message:

The specified message identifier. The application can only use low bytes, and the system uses high bytes.

WParam:

Additional information about related parameters.

LParam:

Additional information about related parameters.

Time:

The time when the message was sent.

Pt:

When a message is sent, it identifies the cursor position of the mouse.

 

Differences between the WM_CREATE message response function and the WM_INITDIALOG message response function:

When responding to the WM_CREATE message response function, the dialog box and sub-control have not been created yet. In other words, the system is notified to start creating the window. After the message is responded, the dialog box and the Child control are created. Therefore, the control cannot be modified or initialized in the message response function.

 

The message response function of WM_INITDIALOG is the message sent when the dialog box and subcontrol are all created and the content is to be displayed. Therefore, you can add initialization and modification to the edit box control in the WM_INITDIALOG message response function.

 

  Finally, I hope to reprint friends can respect the author's labor results, plus reprint address: http://www.cnblogs.com/hanyonglu/archive/2011/04/12/2014220.html thank you.

 

  Complete. Pai_^

 

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.