Windows GDI Learning Notes (2) - Drawing of Windows

xiaoxiao2021-03-06  48

Windows Unified Control Screen Output

Windows As a multi-task operating system, there are multiple task windows on the same interface. Therefore, to ensure that each task window can work normally, the Windows system is responsible for managing all screen outputs to ensure that graphics content can be displayed in their respective windows without interference. All applications must be displayed on the screen via a Windows system.

When to draw a window

The window can be drawn or regenerated in many times, as in the window, size change, remove the window, maximum or minimize the window from other windows. When the content is changed due to a change, the system will issue a WM_PAINT message to the program, the notification program makes the corresponding drawing work, and the BeginPAint function needs to be called before drawing the Device Context, and the endpaint is called after the drawing work is completed. Device context. Of course, graphics drawing can also be performed when other event messages (such as keyboards or mouse events) occurs, and the GetDC or GetDCEX function needs to be invoked before this drawing to get the DEVICE CONTEXT displayed by the graphic display.

Window Drawing Related System Messages

WM_PAINT, WM_NCPAINT, WM_ERASEBKGND

WM_PAINT

WM_PAINT messages are sent to the program when the system draws the window. The program calls the BeginPaint function after receiving the WM_PAINT message to get the current device context to draw the drawing, and then release the Device Context using Endpaint after the drawing is completed.

WM_ncpaint

When the part other than the window customer area (such as window title bar, menu bar, etc.) requires a need to turn, the system issues the message to the program. The required part is required by the client area of ​​the standard window, so that the message will be sent by default to the DefWindowProc function for default. The program can implement custom drawing of the other portions of the window by intercepting the message.

WM_ERASEBKGND

When the window changes, the window background will be resembled. The system first sends a WM_ERASEBKGND message to the program before sending a WM_PAINT message to the program. This message is processed by defWindowProc function, which sets the color properties of WNDCLASS's HBRBACKGROUND to the default system background color to draw background.

转载请注明原文地址:https://www.9cbs.com/read-40702.html

New Post(0)