Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resizing Forms

Status
Not open for further replies.

RossWright

Programmer
Apr 4, 2002
1
US
While painting, I need to be able to detect when a resizing operation on a form is in progress (the user has the mouse button down) and when it has completed (the user has let go of the button). From what I've been able to gather from experimentation and documentation, the only notification provided by WinForms about resizing are the SizeChanged, Resize and Layout events, all of which are called every time the mouse is moved during a resize operation and none of which are called when the user releases the mouse button to stop resizing.

Why do I need this? I am writing an application that does some pretty time consuming rendering. I render to a bitmap which I keep around and then just blit that bitmap when I get an OnPaint instead of re-rendering. The only time I re-render to the bitmap is when the parameters of the data I'm rendering change or... and here's my problem...the user changes the size of the rendering area, the window. Here's some pseudo-code to help explain:

OnPaint
{
if ( data.Changed || (just finished resize operation) )
{
bitmap = data.Render( this.Size )
// This could take a minute or two
}

bitmap.Blit()
}
 
I haven't tried this but I guess you could examine the WM_NCHITTEST message to ascertain when a user is resizing the form - and when the mouse button is eventually released, the WM_SIZE message will be sent, thereby alerting that the sizing operation has completed.

Hope this helps

Neil C
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top