' Module1.bas
Option Explicit
Private Const WM_NCLBUTTONDBLCLK As Long = &HA3&
Private Const HTCAPTION As Long = &H2&
Private Const GWL_WNDPROC As Long = (-4)
Private Declare Function SetWindowLongA Lib "User32.dll" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function CallWindowProcA Lib "User32.dll" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private hWindow As Long
Private func As Long
Public Sub Attatch(ByVal hWnd As Long)
If hWindow = 0 Then
hWindow = hWnd
func = SetWindowLongA(hWindow, GWL_WNDPROC, AddressOf WndProc)
End If
End Sub
Public Sub Detatch()
If hWindow <> 0 Then
Call SetWindowLongA(hWindow, GWL_WNDPROC, func)
hWindow = 0
End If
End Sub
Public Function WndProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If uMsg = WM_NCLBUTTONDBLCLK Then
If wParam = HTCAPTION Then
' TODO:// Something when double clicked.
Debug.Print "Double Clicked: "; Time
End If
End If
WndProc = CallWindowProcA(func, hWnd, uMsg, wParam, lParam)
End Function
' Form1
Option Explicit
Private Sub Form_Load()
Attatch Me.hWnd
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Detatch
End Sub
|