最近刚好看了一编关于虚拟窗口与物理窗口及其升度小区域更新的书籍,你肯定会使用到
以下API函数(请注意LPPAINTSTRUCT lpPaint结构):
The BeginPaint function prepares the specified window for painting and fills a PAINTSTRUCT
structure with information about the painting.
HDC BeginPaint(
HWND hwnd, // handle to window
LPPAINTSTRUCT lpPaint // pointer to structure for paint information
);
Parameters
hwnd
Identifies the window to be repainted.
lpPaint
Pointer to the PAINTSTRUCT structure that will receive painting information.
Return Values
If the function succeeds, the return value is the handle to a display device context for the specified window.
If the function fails, the return value is NULL, indicating that no display device context is available.
Remarks
The BeginPaint function automatically sets the clipping region of the device context to exclude any area outside the update region. The update region is set by the InvalidateRect or InvalidateRgn function and by the system after sizing, moving, creating, scrolling, or any other operation that affects the client area. If the update region is marked for erasing, BeginPaint sends a WM_ERASEBKGND message to the window.
An application should not call BeginPaint except in response to a WM_PAINT message. Each call to BeginPaint must have a corresponding call to the EndPaint function.
If the caret is in the area to be painted, BeginPaint automatically hides the caret to prevent it from being erased.
If the window's class has a background brush, BeginPaint uses that brush to erase the background of the update region before returning.
See Also
EndPaint, InvalidateRect, InvalidateRgn, PAINTSTRUCT, ValidateRect, ValidateRgn
The PAINTSTRUCT structure contains information for an application. This information can be used to paint the client area of a window owned by that application.
typedef struct tagPAINTSTRUCT { // ps
HDC hdc;
BOOL fErase;
RECT rcPaint;
BOOL fRestore;
BOOL fIncUpdate;
BYTE rgbReserved[32];
} PAINTSTRUCT;
Members
hdc
Identifies the display DC to be used for painting.
fErase
Specifies whether the background must be erased. This value is nonzero if the application should erase the background. The application is responsible for erasing the background if a window class is created without a background brush. For more information, see the description of the hbrBackground member of the WNDCLASS structure.
rcPaint
Specifies a RECT structure that specifies the upper left and lower right corners of the rectangle in which the painting is requested.
fRestore
Reserved; used internally by Windows.
fIncUpdate
Reserved; used internally by Windows.
rgbReserved
Reserved; used internally by Windows.
See Also
BeginPaint, RECT, WNDCLASS