Window Resize

G

Guest

Hi there,

Since my last questions wasn't very clear, I will do it in a different way.

I want to resize my app but while resizing I dont want to see content of the
form, I just want to see the window border, then on release, the form
reappears, just like when we use "Show window contents while dragging" on the
windowsXP appearance settings...

Any Ideas in how to do it?
 
G

Guest

Hi Diogo,
you could try not redrawing any of the controls on the form until after
the resize has occurred, at which point you can call Invalidate() to redraw
your form. This will nearly give the effect you are looking for. You would
invalidate on the Idle event of the application when there is no more work to
be processed by the application. For example:

private bool _Idle = false;

protected override void OnResize(EventArgs e)
{
//We only want to do this processing the first time resize is called
if(!_Idle)
{
//add event handler to wait for idle event when we can redraw the
screen
//after a resize has completed
_Idle = true;

//stop any controls being redrawn
this.SuspendLayout();

//add the event handler
Application.Idle += new EventHandler(Application_Idle);
}
base.OnResize (e);
}


private void Application_Idle(object sender, EventArgs e)
{
//if we are idle
if(_Idle)
{
_Idle = false;

//remove the event we do not want it any more
Application.Idle -= new EventHandler(Application_Idle);

//allow controls to be redrawn
this.ResumeLayout();

//cause form to be repainted after the resize
this.Invalidate();
}
}

Hope that helps
Mark R Dawson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Picture Resize Event 3
TabControl flicker issue 1
Change Desktop Max Window Size 4
resize events on windows form 5
WinForm Resize 2
SizeableToolWindow 2
Resize Windows 1
content placeholder 2

Top