Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ValidateRect and InvalidateRect

245 views
Skip to first unread message

terry

unread,
Mar 20, 2008, 12:00:21 AM3/20/08
to
Hi, I am reading the source code in the Grids.pas. the segment make me
confuse:
procedure TInplaceEdit.Invalidate;
var
Cur: TRect;
begin
ValidateRect(Handle, nil);
InvalidateRect(Handle, nil, True);
Windows.GetClientRect(Handle, Cur);
MapWindowPoints(Handle, Grid.Handle, Cur, 2);
ValidateRect(Grid.Handle, @Cur);
InvalidateRect(Grid.Handle, @Cur, False);
end;

why use InvalidateRect function follow the ValidateRect function ?
all help is appreciated! Thank you all in advance!


Remy Lebeau (TeamB)

unread,
Mar 20, 2008, 6:16:28 AM3/20/08
to

"terry" <deng...@tom.com> wrote in message
news:47e1...@newsgroups.borland.com...

> why use InvalidateRect function follow the ValidateRect function ?

ValidateRect() clears out any previous client area that was marked for
drawing, and then InvalidateRect() specifies the new client area that needs
drawing.

> all help is appreciated!

Have you read the documentation for those functions yet?


Gambit


terry

unread,
Mar 20, 2008, 11:54:43 PM3/20/08
to

"Remy Lebeau (TeamB)" <no....@no.spam.com> wrote in message
news:47e23aa2$3...@newsgroups.borland.com...
Yes, I have read the documentation. I just don't understand why it remove
client area from the update region and then adds the client area to update
region. if want to redraw the client area just use InvalidateRect() can do
it; why they call ValidateRect() first?


Ian Boyd

unread,
Jul 1, 2008, 2:15:21 PM7/1/08
to
>> why use InvalidateRect function follow the ValidateRect function ?
>
> ValidateRect() clears out any previous client area that was marked for
> drawing, and then InvalidateRect() specifies the new client area that
> needs drawing.

i guess his question is that if there was an invalid area, how is it that
you've magically determined that it's no longer invalid?

And if you know that the new invalid rect covers any existing invalid area,
you can still let Windows do its job, and just add to the invalid rectangle.

Either way, there's no need to "clear" the old invalid rectangle.


0 new messages