it says Windows restricts painting within the invalid region returned by BeginPaint...this means we cant paint anywhere else on the window?
this is also from petzold's book
Printable View
it says Windows restricts painting within the invalid region returned by BeginPaint...this means we cant paint anywhere else on the window?
this is also from petzold's book
You can paint anywhere in the window. Begin/EndPaint() are just
used to 'redraw' an invalidated area. If you want to 'redraw' the
entire area, you can call InvalidateRect() before Begin/EndPaint()
You'd first need to create a RECT that holds the coordinates ofCode:BOOL InvalidateRect(
HWND hWnd, // handle of window with changed update region
CONST RECT *lpRect, // address of rectangle coordinates
BOOL bErase // erase-background flag
);
the client area of your window. Use GetClientRect()
Code:BOOL GetClientRect(
HWND hWnd, // handle to window
LPRECT lpRect // address of structure for client coordinates
);
Or something like that. Maybe... I don't know. :confused:Code:LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
HDC gdc;
RECT ClientArea;
PAINTSTRUCT ps;
GetClientArea(hwnd, &ClientArea);
switch(msg)
{
case WM_PAINT:
InvalidateRect(hwnd, &ClientArea, false);
gdc = BeginPaint(hwnd, &ps);
EndPaint(hwnd, &ps)
return 0;
break;
default:
break;
}
return (DefWindowProc(hwnd, msg, wParam, lParam));
}
An unoptimized paint routine will simply draw the entire client area and Windows will clip to only the invalidated region. I would start there. If need be, you can get fancy and write your code to only draw to the invalidated region.
gg