VirtualBox

Ignore:
Timestamp:
Oct 7, 2019 6:41:06 PM (5 years ago)
Author:
vboxsync
Message:

Additions/VBoxTray: Added a simple (debug) context menu for the systray to quit VBoxTray in a graceful way. Useful for debugging shutdown code and not having to invoke the task manager all the time.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp

    r79036 r81132  
    11381138        case WM_VBOXTRAY_TRAY_ICON:
    11391139        {
    1140             switch (lParam)
     1140            switch (LOWORD(lParam))
    11411141            {
    11421142                case WM_LBUTTONDBLCLK:
    11431143                    break;
    1144 
     1144#ifdef DEBUG
    11451145                case WM_RBUTTONDOWN:
     1146                {
     1147                    POINT lpCursor;
     1148                    if (GetCursorPos(&lpCursor))
     1149                    {
     1150                        HMENU hContextMenu = CreatePopupMenu();
     1151                        if (hContextMenu)
     1152                        {
     1153                            UINT_PTR uMenuItem = 9999;
     1154                            UINT     fMenuItem = MF_BYPOSITION | MF_STRING;
     1155                            if (InsertMenuW(hContextMenu, UINT_MAX, fMenuItem, uMenuItem, L"Exit"))
     1156                            {
     1157                                SetForegroundWindow(hWnd);
     1158
     1159                                const bool fBlockWhileTracking = true;
     1160
     1161                                UINT fTrack = TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_BOTTOMALIGN;
     1162
     1163                                if (fBlockWhileTracking)
     1164                                    fTrack |= TPM_RETURNCMD | TPM_NONOTIFY;
     1165
     1166                                UINT uMsg = TrackPopupMenu(hContextMenu, fTrack, lpCursor.x, lpCursor.y, 0, hWnd, NULL);
     1167                                if (   uMsg
     1168                                    && fBlockWhileTracking)
     1169                                {
     1170                                    if (uMsg == uMenuItem)
     1171                                        PostMessage(g_hwndToolWindow, WM_QUIT, 0, 0);
     1172                                }
     1173                                else if (!uMsg)
     1174                                    LogFlowFunc(("Tracking popup menu failed with %ld\n", GetLastError()));
     1175                            }
     1176                        }
     1177                    }
    11461178                    break;
     1179                }
     1180#endif
    11471181            }
    11481182            return 0;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette