Docking forms beneath the main form

I have an app with a main form and about 6 sub forms (for setting comm parameters and the like), which can be open or closed by the user's. When they are opened (by a button on the main form), I have it set up so they are the same width as the main, and abutting it at the bottom. That was easy, but when the user moves the main form, how can I make the other forms "tag along"? I thought a combination of mouseDown and mouseMove would do it, but those events aren't generated when dragging the form by the title bar. So what events *are* fired when moving a form?
oldbieAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
freelnceConnect With a Mentor Commented:
Here is a fast but workable answer to your question.  

First place a timer control on your main form and then add the following to the timer event: (adjust the form names and positioning to fit your needs)

Private Sub Timer1_Timer()
  Form2.Move (Me.Left, Me.Top + Me.Height), Form2.Width, Form2.Height
  Form3.Move (Form2.Left + Form2.Width), Form2.Top, Form3.Width,      Form3.Height
End Sub
0
 
BennyBunnyCommented:
Maybe u should make the "mainform" an mdiform and the others mdichilds og this form i guess then they are moving with the parent window
0
 
oldbieAuthor Commented:
This would work, but MDI is not appropriate for this app. A major design goal is to keep the windows as small as possible to leave room for the other apps that will be running. (It's a robotic telescope system with a lot going on at once.) So the idea is to keep the (small) main window open, and open and close sub-windows as needed.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
freelnceCommented:
Do want an "elegant" answer or a fast and workable answer?
0
 
oldbieAuthor Commented:
This works!

I guess the elegant answer involves an API call to hook into the window messages, right?
0
 
freelnceCommented:
You got it.  You would have to subclass the form and intercept the windows move message that accompanies the repositioning of a form.  It is more "elegant" but is also more work and more apt cause errors in the app if an API call is improperly made.

Glad it worked for you.  you might also want to consider placing code to align the secondary forms to the main form if the bottom of the main form is positoined off screen.
0
All Courses

From novice to tech pro — start learning today.