Capture End of Resizing

  • Thread starter Thread starter JezB
  • Start date Start date
J

JezB

I'm having problems simply capturing the end of a form window resize
operation. I want to lay out my form controls each time the user resizes the
form, but this is proving to be more tricky than it sounds.

The Resize() event fires continually WHILE the user is dragging the corner
of the window (I suspect while the windows setting "show window contents
while dragging" is on, but I can't assume it's not). This causes flickering
and very slow repainting.

The new ResizeEnd() event (new in beta 2) doesn't fire continually, only
when the manual resize is finished BUT: it fires when the window is MOVED as
well, and it doesn't fire when the form size changes implicitly when it is
maximised, or un-maximised.

What can I do ?
 
I found a way that works, but in needs the beta 2 ResizeEnd event:

private FormWindowState lastWS;
private Size lastSize;

public Form1()
{
InitializeComponent();
// other stuff here
lastWS = this.WindowState;
lastSize = this.Size;
}

private void Form1_Resize(object sender, EventArgs e)
{
if (this.WindowState != lastWS) // only when window state changed, not
continually on resizing
{
// relayout your screen here
lastWS = this.WindowState;
}
}

private void Form1_ResizeEnd(object sender, EventArgs e)
{
if (this.Size != lastSize) // only when actually resized, not just
after moving the window
{
// relayout your screen here
lastSize = this.Size;
}
}

I hope this helps someone else !
 
one more reason to use beta2...

JezB said:
I found a way that works, but in needs the beta 2 ResizeEnd event:

private FormWindowState lastWS;
private Size lastSize;

public Form1()
{
InitializeComponent();
// other stuff here
lastWS = this.WindowState;
lastSize = this.Size;
}

private void Form1_Resize(object sender, EventArgs e)
{
if (this.WindowState != lastWS) // only when window state changed, not
continually on resizing
{
// relayout your screen here
lastWS = this.WindowState;
}
}

private void Form1_ResizeEnd(object sender, EventArgs e)
{
if (this.Size != lastSize) // only when actually resized, not just
after moving the window
{
// relayout your screen here
lastSize = this.Size;
}
}

I hope this helps someone else !
 
Back
Top