Link to home
Start Free TrialLog in
Avatar of nzfire
nzfire

asked on

LockWindowUpdate - Prevent Flicker

Hi All,

I am using VS2005 and have a form with 2 panels on it.

These panels have a number of buttons on them and some labels. I switch the visibility of these panels over to change what buttons are visible.

I have been using the LockWindowUpdate API call and also SuspendLayout() and ResumeLayout(). This doesn't seem to make much of a difference or help in reducing the flicker.

Is there another way to do this?

Also, using the LockWindowUpdate() seems to cause the whole form to be redrawn when the lock is released.

Thanks
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Avatar of nzfire
nzfire

ASKER

thanks idlemind,

Should I lock the paint first, or set the SuspendLayout first?

What order should the lock and unlock be in basically?
If you have Painting OFF, then you shouldn't need to use SuspendLayout():

    SendMessage(Panel1.Handle, WM_SETREDRAW, False, 0) ' Turn OFF updates

    ' do all your stuff in here...

    SendMessage(Panel1.Handle, WM_SETREDRAW, True, 0) ' Turn ON updates

Though the flicker may be because of all the controls contained in the Panel repainting themselves and not the Panel itself repainting...
Avatar of nzfire

ASKER

sooooo....

does that mean I may have to set all the buttons to lock??

All th buttons have images on them, so I assuming that is causing part of the issue
You should only need to turn off the redraw for the parent object.  Stopping flicker really depends on what you are doing, and the timing of things.  Without more detailed information, it is difficult to offer any useful advice.

BTW SuspendLayout + ResumeLayout is meant to stop multiple layout events from firing, which can optimize your code, but usually doesn't stop flicker (although it can help).

Bob
Avatar of nzfire

ASKER

Hi TheLearnedOne,

Well, the buttons are on a panel, which is the parent. All I am doing is setting the visibility of both panels (one panel sits on top of the other one)

So if I want to view panel 1 - i set its vis to true and panel 2's vis to false...

Its sounds like I do not need to use Suspend and Resume....
What kind of images are we dealing with here?  When does the flicker occur?

Bob
Avatar of nzfire

ASKER

Hi Bob,

When the visibility changes, and they are gif files.

They are not huge, about 2k and there are approx 8 images, and located in the resource file.
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nzfire

ASKER

Thanks TheLearnedOne,

DoubleBuffer helped in this case, considerably. Whilst it did not get rid of the flicker, it reduced it.

Thanks again.