Raoul, thanks for the reply. I tried your timer method and it works like a
charm. I wanted the repositioning of the second form to happen quicker, so
I turned down the Interval on the timer from 500 down to 20 and was unhappy
with the CPU intensity....so....
I made the Main form non-draggable and created a text lbl called lblDragForm
on the form called 'Main' and I can just left or right click and hold on
that label. I then created the following code:
Public Sub lblDragForm_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
'When left mouse button is pressed over Drag box enable dragging
MoveTheForm = True ' Drag is enabled
'Locate where on the Drag box the user has clicked and remember that
position for the lblDragForm routine
StartX = X
StartY = Y
End Sub
Public Sub lblDragForm_MouseUp(Button As Integer, Shift As Integer, X As
Single, Y As Single)
'When left mouse button is released stop the drag and force form to be
within screen borders
MoveTheForm = False ' Drag is disabled
If Main.Left < 0 Then Main.Left = 0
If Main.Top < 0 Then Main.Top = 0
If Main.Top + Main.Height > Screen.Height Then _
Main.Top = Screen.Height - Main.Height
If Main.Left + Main.Width > Screen.Width Then _
Main.Left = Screen.Width - Main.Width
Call RefreshVisibleForm
End Sub
Public Sub lblDragForm_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
'This routine loops while LMB is depress over the Drag box and the mouse is
moved
If MoveTheForm Then
Main.Left = Main.Left - StartX + X
Main.Top = Main.Top - StartY + Y
Call RefreshVisibleForm
End If
End Sub
Private Sub RefreshVisibleForm()
Select Case ComboMenu.ListIndex
Case 0
frmIntroduction.Top = Main.Top + VerticalOffset
frmIntroduction.Left = Main.Left
frmIntroduction.Show
Case 1
frmMaterialsRequired.Top = Main.Top + VerticalOffset
frmMaterialsRequired.Left = Main.Left
frmMaterialsRequired.Show
Case 2
frmGettingStarted.Top = Main.Top + VerticalOffset
frmGettingStarted.Left = Main.Left
frmGettingStarted.Show
<snip>
End Select
End Sub
This is an unconvential way of dragging a form, but if it works, why not!
Tom
"Raoul Watson" <Wa*****@IntelligenCIA.com> wrote in message
news:cD*******************@nwrdny03.gnilink.net...
"Kiteman - Canada" <-d*************@shaw.ca> wrote in message
news:sNxjc.271888$Pk3.212594@pd7tw1no... Is there an event triggered when a form is dragged by its titlebar?
I have two forms on screen - the main form is draggable and I need the
secondary form to automatically reposition itself adjacent to the main
form if the main form is relocated.
Tom
Without subclassing the window, all I can think of is save Me.left and
me.top on form activate.
Have a timer event that checks If Me.Left <> oldleft Or Me.Top <> oldtop
Then <form has been moved>