Solved

How can I tell when an MDI child is being moved?

Posted on 2006-12-01
5
395 Views
Last Modified: 2008-01-09

Is there a way to definitievely tell when an MDI child form is starting to move, is moving, and when the user has finished moving?  This could be limited to when the user clicks on the title bar and drags it (rather than programmatically, I guess), if necessary.  

I have been playing around with the Move event and the MouseCaptureChanged event, but these (MouseCaptureChanged especially) are strange and can't seem to nail down the actual events I want.  What's the capital-R Right way to do this?

0
Comment
Question by:riceman0
  • 3
5 Comments
 

Author Comment

by:riceman0
ID: 18057980

By the way, I need to know the exact spot that the move started, since in some cases I want to restore to the pre-move location.  I don't think trapping the first Move event will accomplish this...

Another constraint: I don't think I want to override the WndProc procedure to get a mouse click on the title bar (that's how you do that, right?)  I am handling all this through a separate, central class to which I am passing a reference to each child form.  I do not think I can intercept WndProc messages through a reference (using AddHandler or something), correct?  Hope that makes sense.
0
 

Author Comment

by:riceman0
ID: 18058000

Maybe one way to do this is this:

Is Form.MouseCaptureChanged called both when the form receives and loses the capture?  If so, how do I distingusih the two events??
0
 
LVL 34

Accepted Solution

by:
Sancler earned 500 total points
ID: 18058119
I assume, from your reference to Form.MouseCaptureChanged, that you are on VB.NET 2005.  If that's so, have a look at Form.ResizeBegin and Form.ResizeEnd.  They seem to offer just what you want.

Roger
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 18058671
You'll also need the Move() or the LocationChanged() event.

So just pass the form to your central class and then use AddHandler() to wire those events up in it.

Unfortunately the ResizeBegin()/ResizeEnd() events also fire when the form is resized (thus the name) as well as moved so you won't be able to tell the difference between the two.
0
 

Author Comment

by:riceman0
ID: 18059802
ResizeBegin works okay for me, I'll just remember the position before both resizes and moves, and only use the positions before moves.  Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now