The Paint Structure

Started by sukishan, Jul 12, 2009, 06:40 PM

Previous topic - Next topic

sukishan


The Paint Structure(PAINTSTRUCT)

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;


hdc Handle to 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 the system.
fIncUpdate Reserved used internally by the system.
rgbReserved Reserved used internally by the system.
Windows erases the background using the brush specified in the hbrBackground field of the WNDCLASS structure that is used when registering the window class during WinMain initialization. Many windows programs specify a white brush for the windows background. This is indicated in the program with the statement like this:

wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;

The second method to get a handle to DC of the client area of the windows js by calling GetDC to obtain the handle and ReleaseDC to release the handle. This can be done with the statement like this:

hdc = GetDC (hwnd) ;

[ GDI functions]

ReleaseDC (hwnd,hdc);

The functions GetDC and ReleaseDC should be called in pairs like BeginPaint and EndPaint. GetDC is used while processing message and ReleaseDC is used to exit the window procedure. Do not call GetDC in one message and ReleaseDC in another message. A function similar to GetDC is GetWindowDC. While GetDC returns a device context handle for writing on the client area of the window, GetWindowDC returns a device context handle for writing on the entire window.To use the function GetWindowDC your program has to process WM_NCPAINT (non client paint) message.

A good beginning makes a good ending