471,354 Members | 1,213 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

Moving form objects around

I need to be able to move a few form abouts around after a event occurs
but when I do this it causes massive flickering is there any way to
reduce this?

Dec 8 '05 #1
6 1357

Checkout the SuspendLayout and ResumeLayout methods.

Also, what event are you talking about? It really depends how often you
want your form to draw. Every pixel of the movement? Only when it gets
to its destination?

Steven Nagy

Dec 8 '05 #2
Thanks for the suggestion but I am still seeing the flickering. Its
button that the user clicks that causes the form layout to require a

Dec 8 '05 #3
Stick your code on here for the button event (just the important stuff)
and also try to answer some of my other questions. We'll get you

Dec 8 '05 #4
private void Form_Resize(object sender, System.EventArgs e)
// Panel1, and Custom1 are aligned top left as well.
// Panel1 surrounds Custom1 + 1 Pix this is implied below.
// Custom 1 uses GDI+ and has a Scroll bar that may or may not be
visible on the
// right side
// CustomTo*Edge calculated at load time distance from the * to the
Edge of the form.
// Keep this constant.
Custom1.Width = ClientRectangle.Width - Custom1.Left -
Custom1.Height = ClientRectangle.Height - Custom1.Top -
// Recalculate and .Value member of the scroll bar so the user does
not get confused.
Custom1.RecalcScrollBar ();
panel1.Width = ClientRectangle.Width - panel1.Left - CustomToRightEdge
+ 2;
panel1.Height = ClientRectangle.Height - panel1.Top -
CustomToBottomEdge + 2;
leadsControl1.ResumeLayout(true); // If false scroll bar does not

There is also a Custom control that is docked to the left side but it
does not flicker. And a label1 that is aligned to Top, Left that
requires no more complex logic, again it does not flicker. Flickering
is most apparent when resizing along the left edge of the Form.

It is possible to collapse panel1 and custom1 into one control, but it
would require calculating where the scroll bar is. The panel simply
draws a black box around custom1. I have also tried the WM_SETREDRAW
workaround however there is bleeding from what is behind the form while
the user is resizing, but the flicker is gone.

Dec 9 '05 #5
I just figured out that most of the logic above save the recalc scroll
bar and invalidate can be avoided by simply aligning to all edges
however this does not solve the problem of flickering. But it helped

Dec 9 '05 #6
Whats generally happening in the RecalcScrollBar method? Are you also
invalidating the control in there?

Dec 11 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Garma | last post: by
5 posts views Thread by Fabri | last post: by
reply views Thread by Ben Hoffman | last post: by
2 posts views Thread by matt | last post: by
2 posts views Thread by Lady Di | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.