Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: How to know when a forms title bar is clicked???


Message #1 by "Mark E. Watkins" <markw@l...> on Fri, 8 Dec 2000 14:39:18 -0600
Hey Mark,
Here is the sample code for identifying double click in a Title Bar. 
For more information see subclassing in MSDN.

Create a new standard Exe project with 
(1) From1.Frm
(1) Module1.Bas

Put the below Code in Module1.Bas
******************************************
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

Declare Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Public Const GWL_WNDPROC = -4
Public Const WM_DBLCLICK = 163
Global lpPrevWndProc As Long

Function WindowProc(ByVal hw As Long, ByVal uMsg As _
Long, ByVal wParam As Long, ByVal lParam As Long) As _
Long
    If uMsg = WM_DBLCLICK Then
       MsgBox "You Double Clicked My Title Bar"
    End If
   WindowProc = CallWindowProc(lpPrevWndProc, hw, _
   uMsg, wParam, lParam)
End Function

***********************************
Put Below Code in From1.Frm
************************************
Public Sub form_load()

   lpPrevWndProc = SetWindowLong(Me.hwnd, GWL_WNDPROC, _
   AddressOf WindowProc)
End Sub

Private Sub Form_Unload(Cancel As Integer)
   Dim temp As Long
   temp = SetWindowLong(Me.hwnd, GWL_WNDPROC, _
   lpPrevWndProc)

End Sub

***********************************
You may find it little difficult to step through in Debug mode, but should
be able
to execute and see the result. If you put this code in your application,
better comment it out
while debugging other areas of your code and uncomment it once application
is ready.

Let me know if you have any problem in executing this.

Enjoy
Liju Thomas



> -----Original Message-----
> From:	Mark E. Watkins [SMTP:markw@l...]
> Sent:	Friday, December 08, 2000 2:39 PM
> To:	professional vb
> Subject:	[pro_vb] How to know when a forms title bar is clicked???
> 
> Hi,
> 
> Does anyone know of an API call or any other way to know when a forms
> Title
> bar has been double clicked.  I have a treeview that covers the entire
> client area of a form; therefore, leaving only the Title bar exposed and I
> want to be able to capture when the user double clicks it.
> 
> Thanks for any help you all can offer.
> 
> 

  Return to Index