9.windows message Mechanism (iv)

Source: Internet
Author: User

1. Drawing messages

WM_PAINT-the window processing function is sent when the window needs to be drawn.

Situations where repainting is required:

(1) window from creation to first display

(2) from being obscured to re-displaying

(3) The window becomes larger (the window becomes the hour, the window itself does not need to be re-cs_hredraw, but if the registration window class is added | Cs_vredraw style, will be redrawn)

(4) Call the InvalidateRect function

Invalid window area-declared as an area that needs to be redrawn.

BOOL InvalidateRect (HWND hwnd,//Window handle

CONST rect* LpRect,//rectangle coordinates of the area

BOOL bErase); Whether to erase before re-return

In the program, if you need to draw the window, call the Function declaration window invalid area.

WPARAM-Do not use

LPARAM-Do not use

Message processing steps

(1) Start drawing processing

HDC BeginPaint (HWND hwnd,//drawing window

Lppaintstruct lppaint); Buffer for drawing parameters

Returns the drawing device handle HDC

(2) Drawing

(3) Finish drawing

BOOL EndPaint (HWND hwnd,//drawing window

CONST paintstruct *lppaint); Pointers to drawing parameters

2. Keyboard messages

Wm_keydown-generated when the key is pressed

Wm_keyup-generated when the button is released

Wm_syskeydown-generated when the system key is pressed, such as ALT, F10

Wm_syskeyup-generated when System key is released

WM_CHAR-Character message (TranslateMessage sent)

Message parameters:

Key message: WPARAM-Key Virtual key

LPARAM-key parameters, such as the number of presses

WM_CHAR message:

WPARAM-Input character (ASC character encoding)

LPARAM-Parameters related to keys

9.windows message Mechanism (iv)

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.