Difference between revisions of "Form Events and Capabilities VB6"
From Free Knowledge Base- The DUCK Project: information for everyone
m |
m (Form Move Event moved to Form Move Event VB6) |
(No difference)
|
Revision as of 07:00, 2 February 2008
- Microsoft VB .NET has a form_move event, but Visual BASIC 6 does not.
- The Paint event won't detect a window being moved off the screen, but will get triggered when the window is moved back onto the screen. If AutoRedraw is enabled the Paint event is not fired at all.
- GotFocus/LostFocus Events are not triggered by the form.
- Form_MouseMove is fired when the mouse cursor is over the form, not including the title bar. However, dragging is done with the title bar.
Your options are:
Subclassing using WM_WINDOWPOSCHANGED
Subclassing can make the Visual Studio IDE unstable. The debugger does not work well when a new WindowProc is installed.
EventVB.dll Custom Functions
First add the EventVB.dll to your project references. It is not included with Visual Studio.
Option Explicit Dim WithEvents vbLink As EventVB.APIFunctions Dim WithEvents vbWnd As EventVB.ApiWindow Private Sub Form_Load() Set vbLink = New APIFunctions Set vbWnd = New ApiWindow vbWnd.hWnd = Me.hWnd '\\ Subclass this form vbLink.SubclassedWindows.Add vbWnd End Sub Private Sub vbWnd_Move(ByVal x As Long, ByVal y As Long, Cancel As Boolean) '\\ This event occurs when a drag-move completes: Debug.Print "Moved to " & x & "," & y End Sub Private Sub vbWnd_Moving(ByVal MoveEdges As EventVB.WindowSizingEdges, MoveRectangle As EventVB.APIRect) '\\ This event occurs during the drag-move With MoveRectangle Debug.Print "Moving to " & .Left & "," & .Top & " - " & .Right & "," & .Bottom End With End Sub