View painting mechanism

zhaozj2021-02-08  277

View painting mechanism

In VC documents, view structures, CVIEW's OnDRAW function is used to achieve most of the graphics drawing. If the user changes the window size, or the hidden area is displayed, the onDraw function will call the window. Also, when the data in the program document changes, it is generally necessary to inform the change of Windows by calling the INVALIDATE (or InValidateRect) member function of the view, and the call to the InvalIDate will also trigger the call to the onDraw function. Because the onDraw function is frequently called, it will make the screen unstable and flicker each time it is implemented. In fact, a Windows message is triggered before the program calls the onDraw function: WM_ERASEBKGND to erase the view refreshed the area. By default, the Windows system uses the brush described by the member hbrbackground in the window class when registering the window class, which generally refreshes the screen into the color corresponding to the Color_Window. Therefore, the execution process of setting the background color in the onDraw function is this: first refresh the screen into the color corresponding to the color_window, and then fill other colors in the onDRAW function, which is the root cause of the screen flashing. ONCTLCOLOR () function, call this function when the dialog is ready to display a control, it returns a HBrush for drawing control background

(I wrote a point on learning VC, looking to the same thing to point to the law).

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

New Post(0)