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

WM_SETREDRAW causes desktop to show through

712 views
Skip to first unread message

djc

unread,
Aug 29, 2003, 2:54:17 AM8/29/03
to
Hi,

I am using WM_SETREDRAW to disable a form from painting until I finish
making changes to it. The problem is that while the form is in this
no-updates mode, moving the mouse over the form causes items from the window
underneath to show through.

For example, my form is in front of an IE window. If I disable redraw for 1
second using WM_SETREDRAW, during this second I can move my mouse over the
form and images from IE show through onto my form. How can I stop this
behaviour, it is totally unwanted?

--
djc


Kurt Barthelmess (TeamB)

unread,
Aug 29, 2003, 7:13:13 AM8/29/03
to
"djc" <d...@c.com> wrote:

What would be an acceptable alternative? You've said you don't want to
draw your stuff. But the display or screen is going to display pixels.
So what pixels do you want it to show?

You'll have similar problems if any portion of your window gets
invalidated while you've inhibited drawing - the pixels you aren't
drawing are still part of the physical display and have to show
something.

Good luck.

Kurt


djc

unread,
Aug 29, 2003, 8:54:51 AM8/29/03
to
I would like to freeze the display the way it was until drawing is complete.

Is there any other way to accomplish this?

--
djc

Marc Rohloff

unread,
Aug 29, 2003, 9:10:31 AM8/29/03
to
> Is there any other way to accomplish this?
LockWindowUpdate

Marc

djc

unread,
Aug 29, 2003, 10:16:29 AM8/29/03
to
"Marc Rohloff" <marc rohloff at bigfoot dot com> wrote in message
news:MPG.19b91acf8...@newsgroups.borland.com...

> > Is there any other way to accomplish this?
> LockWindowUpdate
>

Tried that, and it worked pretty good (I don't think there were any
drawbacks). However I heard that it was not good to use LockWindowUpdate()
because it forces the whole desktop to be redrawn after the unlock; and only
one window can be locked at any time in the whole o/s so this could
introduce sync problems.

--
djc


Marc Rohloff

unread,
Aug 29, 2003, 10:24:01 AM8/29/03
to
> ... I heard that it was not good to use LockWindowUpdate()

> because it forces the whole desktop to be redrawn after the unlock;
I have never heard of this, although often people call LockWindowsUpdate
with the desktop window handle to lock everything which also means that
the whole of windows seems to freeze (Great when debugging :) )

> one window can be locked at any time in the whole o/s so this could
> introduce sync problems.

Yes this is the down side but I have found that the SetRedraw method
doesn't work consistently on everything and has it's own quirks.

Marc

djc

unread,
Aug 29, 2003, 10:25:42 AM8/29/03
to
So are these two my only options? Can the double-buffering flag in Delphi be
off any assistance?

--
djc


Marc Rohloff

unread,
Aug 29, 2003, 11:36:23 AM8/29/03
to
On Sat, 30 Aug 2003 00:25:42 +1000, djc<d...@c.com> said ...

> Can the double-buffering flag in Delphi be
> off any assistance?
I don't believe so

> So are these two my only options?

No,

1) Instead of painting to the form paint to your own canvas and then copy
that to the form when you are finished.

2) You could overwrite the Paint method to do something else in this
period (Nothing, Paint the form grey, show a picture of the Alps)

3) You could cover everything with a panel during this period and show
something else.

4) You could save a bitmap of your form before starting and then using
method 2) or 3) display that bitmap to the user until you are ready to
continue.

What exactly are you doing and how are you doing it?

Marc

Chris Luck

unread,
Aug 29, 2003, 3:01:23 PM8/29/03
to
"djc" <d...@c.com> wrote in message news:3f4e...@newsgroups.borland.com...

> I am using WM_SETREDRAW to disable a form from painting until I finish
> making changes to it.

I don't know if this will usefully influence your drawing prob. but as you are
wanting to effectively disable the form, why not literally disable it instead?

MyForm.Disabled := true;

Worth a shot, what? Use a try..finally block of course.

--
Regards,
Chris Luck.

djc

unread,
Aug 29, 2003, 11:36:54 PM8/29/03
to
Ok, this is what I am doing. I have an app similar to Outlook (or Outlook
Express) where there is a tree view component on the left (showing folders)
and a listview component on the right.

When the user clicks on a different folder, I destroy the old listview
component, create a new one, fill it up with data, then align it to the
client area, set the parent to the form, and then it shows up.

The problem is after deleting the old listview, the screen flashes the grey
background for an instant. After setting the listviews parent to the form,
the listview shows up for an instant in the wrong position (it is at the
top-left corner of the form) until it has had a chance to align itself
properly.

As you know, when you change folders in Outlook or OE, it doesn't flicker
components all over the place. It might not even destroy the old component
in the first place - I don't know, but I should still be able to do it my
way.

Using WM_SETREDRAW worked well, except for the problem I mentioned that for
a fraction of a second parts of the form that is behind my form can show up.

--
djc

Kurt Barthelmess (TeamB)

unread,
Aug 30, 2003, 7:27:21 AM8/30/03
to
"djc" <d...@c.com> wrote:

>When the user clicks on a different folder, I destroy the old listview
>component, create a new one, fill it up with data, then align it to the
>client area, set the parent to the form, and then it shows up.
>
>The problem is after deleting the old listview, the screen flashes the grey
>background for an instant. After setting the listviews parent to the form,
>the listview shows up for an instant in the wrong position (it is at the
>top-left corner of the form) until it has had a chance to align itself
>properly.
>
>As you know, when you change folders in Outlook or OE, it doesn't flicker
>components all over the place. It might not even destroy the old component
>in the first place - I don't know, but I should still be able to do it my
>way.

1) Leave the old listview as is while you create and populate the new
one. That ensures the old data remains while you work.

2) Create the new listview with Visible = False and leave it so until
you are done populating and moving and sizing it. Then make it
visible.

3) Destroy the old listview after making the new listview visible.

Good luck.

Kurt


djc

unread,
Aug 30, 2003, 9:33:15 AM8/30/03
to
Hi Kurt,

Actually, that is how I was doing it previously but I thought WM_SETREDRAW
would be easier. I had to resize the new component to align to the client
manually though before making it visible, because it won't do it
automatically unless it is visible but then you can see it resize
(flickers).

So I go:
1. Create new component
2. Populate with data.
3. Set align to client (won't do anything yet cause its not visible).
4. Align it manually to the client area
5. Set parent to the form.
6. Destroy old component.

If this is the best way to do it, then that's ok. Thanks for your help then.

--
djc

0 new messages