views:

37

answers:

1

i know how to repaint the full window but i don't know how to repaint a pieace of window like i draw a squre using gdi+ than i want to change it's coordinates so i want to repaint the squre not the whole window
anyidea?


i also tried this

RECT rect2;
rect2.left=0;
rect2.top=100;
rect2.right=225;
rect2.bottom=300;
InvadiateRect(hwnd, &rect2, false);

it still repaint the whole window

+1  A: 

One way to do this is to call InvalidateRect() with a rectangle that is large enough to cover both the old and new positions of the square you moved. Windows will then call your WM_PAINT handler to repaint the area of the screen that changed.

The UnionRect() function is helpful for calculating this repaint rectangle.

Greg Hewgill
i tried wat you suggested me but didn't reall work. i created a rect structure with x and y coordinates but still repaint the whole window
Ramiz Toma
When you call `BeginPaint()`, you get back a `PAINTSTRUCT` structure that contains a `rcPaint` member. You can limit the amount of your window that you paint by looking at `rcPaint` in your `WM_PAINT` handler.
Greg Hewgill