Results 1 to 3 of 3

Thread: Ok, ya know when you dblclk on a app's title bar and...

  1. #1

    Thread Starter
    Addicted Member Daniel_Christie's Avatar
    Join Date
    Jan 2000
    Location
    USA
    Posts
    245
    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?
    I appreciate all of your time and effort,
    Daniel Christie
    VB 5 and 6 Enterprise Editions,
    Html, Java scipt, Vb script,
    & etc...
    http://www.qwcd.com

  2. #2
    Guest
    Simply subclass the WM_NCLBUTTONDBLCLK message (which occurs when the titlebar is double clicked)

    Code for a Module
    Code:
    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
    Code:
    Private Sub Form_Load()
        SubClassWnd hwnd
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        UnSubclassWnd hwnd
    End Sub

  3. #3

    Thread Starter
    Addicted Member Daniel_Christie's Avatar
    Join Date
    Jan 2000
    Location
    USA
    Posts
    245

    Megatron, I thank you.

    Yes!

    That's what I needed, Much appreciated.








    I appreciate all of your time and effort,
    Daniel Christie
    VB 5 and 6 Enterprise Editions,
    Html, Java scipt, Vb script,
    & etc...
    http://www.qwcd.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width