Advertisement
6_2008-2009 Custom Controls/ Forms/ Menus #200260

Move forms together

Move forms together as if they were docked. No Timer needed! I had to separate forms used as a kind of toolbox. My idea was, that it would be nice if I could move these two together if they were both active. VB doesn't tell me when my form is moved. But then I realised that I read s.th. about moving forms without a titlebar. Using this trick my code will perform the following action: 1. The form detects a mousedown event 2. The mouse is released and the form moved by FormDrag 3. The other form is notified of the movement 4. The other form will follow the first Don't forget to vote if you like it ;o)

AI

Resumen de IA: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Código fuente
original-source
'Put this in a global module
Public Sub FormDrag(TheForm As Form)
  ReleaseCapture
  Call SendMessage(TheForm.hwnd, &HA1, 2, 0&)
End Sub
'this code has to be in your form
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  FormDrag Me 'move form
  NameOfOtherForm.MoveMe 'notify other form
End Sub
'this is needed in the second form
Public Sub MoveMe()
  If Top > NameOfOtherForm.Top Then
    Top = NameOfOtherForm.Top + NewFrm.Height 'Place below other form
    Left = NameOfOtherForm.Left
  Else
    Top = NameOfOtherForm.Top - Height     'Place above other form
    Left = NameOfOtherForm.Left
  End If
End Sub
Comentarios originales (3)
Recuperado de Wayback Machine