The Paint Structure

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

Previous topic - Next topic


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];


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

Quick Reply

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it has been approved by a moderator.

Please leave this box empty:
Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

Shortcuts: ALT+S post or ALT+P preview