表单相黏问题
不知道这问题有没有人提过,除了用Timer及时侦测外,有没有其他方式,可以在A和B两个表单同时出现时,
让B表单随着A表单的移动,而跟这移动?
实验后发现Form上的SystemMenu好像不在Form的事件控制范围内
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Public Const GWL_WNDPROC = (-4) Public Const WM_MOVE = &H3 Public lOldProc As Long Public Function wndProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long If Msg = WM_MOVE Then Call Form1.WindowMove End If wndProc = CallWindowProc(lOldProc, hWnd, Msg, wParam, lParam) End Function
Dim fm As Form2 Private Sub Form_Load() Set fm = New Form2 fm.Show 0 lOldProc = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf wndProc) End Sub Private Sub Form_Unload(Cancel As Integer) Unload fm SetWindowLong hWnd, GWL_WNDPROC, lOldProc End Sub Public Sub WindowMove() If Me.WindowState = vbMaximized Then Exit Sub If fm.Visible Then fm.Move Form1.Left + Form1.Width, Form1.Top End If End Sub