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 the user closes the main menu
DescriptionThis example shows how to determine when the user closes the main menu in Visual Basic 6.
Keywordsmenu, main menu, close, subclass, WindowProc
CategoriesAPI, Controls
 
Subclass and watch for the WM_EXITMENULOOP message.
 
' Look for main menu close.
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
Const WM_MENUSELECT As Long = &H11F
Const WM_EXITMENULOOP As Long = &H212

    ' Load the message names.
    LoadMsgNames

    If msg = WM_EXITMENULOOP Then Debug.Print Hex$(msg) & _
        ": " & MsgName(msg)

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

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