PDA

Click to See Complete Forum and Search --> : Ok, ya know when you dblclk on a app's title bar and...


Daniel_Christie
Nov 2nd, 2000, 01:34 PM
Ok, ya know when you dblclk on a app's title bar and the app minimizes. well, I would like to code it to do something else other than a minimize function. Is this possible and if so how can this be coded?

Nov 2nd, 2000, 02:22 PM
Simply subclass the WM_NCLBUTTONDBLCLK message (which occurs when the titlebar is double clicked)

Code for a Module

Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
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
Const GWL_WNDPROC = (-4)
Const WM_NCLBUTTONDBLCLK = &HA3

Global WndProcOld As Long

Public Function WindProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

If wMsg = WM_NCLBUTTONDBLCLK Then
'Do another command here
MsgBox "You double clicked the titlebar; You App will not change state"
Exit Function
End If

WindProc = CallWindowProc(WndProcOld&, hwnd&, wMsg&, wParam&, lParam&)

End Function

Sub SubClassWnd(hwnd As Long)
WndProcOld& = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindProc)
End Sub

Sub UnSubclassWnd(hwnd As Long)
SetWindowLong hwnd, GWL_WNDPROC, WndProcOld&
WndProcOld& = 0
End Sub


Code for a Form

Private Sub Form_Load()
SubClassWnd hwnd
End Sub

Private Sub Form_Unload(Cancel As Integer)
UnSubclassWnd hwnd
End Sub

Daniel_Christie
Nov 2nd, 2000, 02:51 PM
Yes!

That's what I needed, Much appreciated.