Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleDetermine when a ComboBox is about to drop down
KeywordsComboBox, down event, dropdown event
CategoriesControls, API
 
Subclass using a WindowProc to detect WM_COMMAND messages sent to the ComboBox. Look for the CBM_DROPDOWN message.
 
' Look for the ComboBox drop down.
Public Function NewWindowProc(ByVal hWnd As Long, ByVal msg _
    As Long, ByVal wParam As Long, ByVal lParam As Long) As _
    Long
Const WM_NCDESTROY = &H82

    ' If we're being destroyed,
    ' restore the original WindowProc.
    If msg = WM_NCDESTROY Then
        SetWindowLong _
            hWnd, GWL_WNDPROC, _
            OldWindowProc
    End If

    If msg = WM_COMMAND And _
        ComboHwnd = (lParam And &HFFFF) And _
        (wParam \ &H10000) = CBN_DROPDOWN _
    Then
        ' The ComboBox is being dropped down.
        Beep
    End If

    NewWindowProc = CallWindowProc( _
        OldWindowProc, hWnd, msg, wParam, _
        lParam)
End Function
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated