Article ID: 114593
Article Last Modified on 12/9/2003
Type POINTAPI ' Used for GetCursor - gets mouse location
X As Integer ' in screen coordinates.
Y As Integer
End Type
Type ConvertPOINTAPI ' Used by WM_SYSCOMMAND - converts mouse location.
xy As Long
End Type
' Enter the following Declare statement as one, single line:
Declare Function Sendmessage Lib "User" (ByVal hwnd As Integer,
ByVal wMsg As Integer, ByVal wParam As Integer,
ByVal lParam As Any) As Long
Declare Sub GetCursorPos Lib "User" (lpPoint As POINTAPI)
Global Const WM_LBUTTONUP = &H202
Global Const WM_SYSCOMMAND = &H112
Global Const MOUSE_MOVE = &HF012
Sub Form_Load()
Form1.Caption = ""
Label1.Caption = "Click Here to Move the Form"
Label1.BorderStyle = 1 ' Place a border around the label.
Label1.AutoSize = True
' Position the label at the top of the form:
Label1.Move 0, 0, Me.ScaleWidth
End Sub
Sub Label1_MouseDown ()
Dim mpos As POINTAPI
Dim p As ConvertPOINTAPI
Dim ret As Integer
Call GetCursorPos(mpos) ' Get the current position of the cursor
LSet p = mpos ' and convert it for SendMessage calls.
' Send LButtonUp to finish the impending LButtonDown.
' This line of code will invoke the Label1_MouseUp() event,
' so be careful what code you place in that event:
ret = Sendmessage(Me.hWnd, WM_LBUTTONUP, 0, p.xy)
' NOTE: If you are using a control that has a Window Handle
'(hWnd) as your hot spot, then that control is receiving the
' mouse messages and you need to send the WM_LBUTTONUP message
' to that control, not the form. Therefore, you would need
' to change the above line of code to read:
'
' ret = SendMessage(MyControl.hWnd, WM_LBUTTONUP, 0, p.xy)
'
' where MyControl is the control you are using as the hot spot
' Now tell the form someone is clicking the window caption:
ret = Sendmessage(Me.hWnd, WM_SYSCOMMAND, MOUSE_MOVE, p.xy)
End Sub
Additional query words: 2.00 3.00 hotspot
Keywords: kbwndw kbcode KB114593