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
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
Is there any other way to accomplish this?
--
djc
Marc
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
> 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
> 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
> 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.
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
>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
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