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

WM_SETREDRAW

224 views
Skip to first unread message

Mike Mallory

unread,
Apr 9, 1999, 3:00:00 AM4/9/99
to
All right guys. The use of LockWindowUpdate is well known. How about a
tutorial on the use of WM_SETREDRAW. This message is poorly documented
at best. LockWindowUpdate works 'out of the box' but WM_SETREDRAW
obviously need some 'pre' and 'post' code to go with it. So how about
helping out your poor brethren?

-Mike

Damon Chandler

unread,
Apr 9, 1999, 3:00:00 AM4/9/99
to
Mike,
WM_SETREDRAW is a message that can be sent to a Window to
disable/enable screen updating. The WParam (WORD paramter) of the
message is a state (boolean) to tell the window to disable (false) or
enable (true) updating. The LParam (LONG parameter) is not used and
should be 0. To send the message to the window, you can use the
SendMessage() API function or the VCL Perform method. Here's an
example...

____________________________________________________________________

//turn updating off (same as LockWindowUpdate(ListView1->Handle))
ListView1->Perform(WM_SETREDRAW, false, 0);

for (int index = 1; index < 500; index++)
{
TListItem *NewItem = ListView1->Items->Add();
NewItem->Caption = "ListItem" + IntToStr(index);
}

//turn updating back on (same as LockWindowUpdate(NULL))
ListView1->Perform(WM_SETREDRAW, true, 0);
_____________________________________________________________________


Try the code with and without the WM_SETREDRAW message, and you'll see a
huge difference in execution time. Hope this clears things up.


//Damon

-------------------------------------
http://bcbcaq.freeservers.com
Answers to <Commonly Asked Questions>

Stefan Hoffmeister (TeamB)

unread,
Apr 9, 1999, 3:00:00 AM4/9/99
to
: Damon Chandler <dm...@cornell.edu> wrote:

>//turn updating off (same as LockWindowUpdate(ListView1->Handle))
>ListView1->Perform(WM_SETREDRAW, false, 0);

The only thing I have to add here is that in real-world code this
should be protected in a try __finally:

ListView1->Perform(WM_SETREDRAW, false, 0);
try
{ ... }
__finally
{
ListView1->Perform(WM_SETREDRAW, true, 0);
}


--
Stefan Hoffmeister (TeamB) http://www.econos.de/
Please do apply judgement when sending email.

Mike Mallory

unread,
Apr 24, 1999, 3:00:00 AM4/24/99
to
Thanks Damon, Stefan,

I've been otherwise occupied the last couple of weeks and haven't had a
chance to get back here. My problem is when I use WM_SETREDRAW with a
MDIParent form, it doesn't seem to inhibit the drawing of my child forms
(LockWindowUpdate does, although with some flicker on the desktop). Any
further help would be appreciated.

- Mike

Mike Mallory

unread,
Apr 24, 1999, 3:00:00 AM4/24/99
to
Well, maybe not a couple of weeks. I should pay more attention.

- Mike

0 new messages