Ramilol
Ramilol

Reputation: 3462

c++ repaint part of window

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

Upvotes: 1

Views: 468

Answers (1)

Greg Hewgill
Greg Hewgill

Reputation: 992857

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.

Upvotes: 1

Related Questions