| Previous | Next |
| ERROR_NON_MDICHILD_WINDOW | ERROR_NO_SCROLLBARS |
ERROR_POPUP_ALREADY_ACTIVE
A popup menu is already being tracked on the GUI thread.
ERROR_POPUP_ALREADY_ACTIVE is Win32 error 1446 (0x5A6). Popup-menu tracking is a modal USER32 operation. Starting another tracked popup while the current thread is still inside an active menu loop can fail because the input, capture, selection, and dismissal state belongs to the first menu.
Common reentrancy paths
- a menu command handler immediately opens another context menu
- a hook or callback invokes
TrackPopupMenuExduring the existing menu loop - mouse or keyboard automation causes nested popup creation
- two components share a UI thread but do not coordinate menu ownership
- a custom owner-drawn menu posts work that synchronously starts a second popup
Data worth preserving
Log the thread ID, owner window, menu handle, invocation source, input event, flags passed to TrackPopupMenu or TrackPopupMenuEx, and a nesting counter around the application’s menu helper. Record whether the first call uses TPM_RETURNCMD and when it actually returns. The visible menu may disappear before all related callbacks have unwound.
Diagnostic approach
Instrument every popup entry and exit on the thread. Identify synchronous callbacks triggered while menu tracking is active, including WM_INITMENUPOPUP, owner-draw messages, command routing, accessibility events, and hooks. A nested call often appears several stack frames away from the original menu helper.
Check whether the application opens a submenu through normal menu resources or incorrectly starts a separate tracking operation. USER32 manages true submenus within the original menu hierarchy; application code should not emulate them with another top-level popup call.
Recovery
Defer the second menu request with PostMessage until the first tracking function returns, or queue it in application state and open it after the modal loop ends. Guard the shared menu helper against nesting and decide which request wins. Calling EndMenu may be appropriate for an explicit cancel flow, but it should not be used merely to force arbitrary nested menus.
Difference from menu identity errors
ERROR_INVALID_MENU_HANDLE says the supplied HMENU is invalid. ERROR_MENU_ITEM_NOT_FOUND says a requested item is absent. Error 1446 instead reports conflicting active menu-loop state.
Example
A right-click menu contains “Choose profile,” whose handler synchronously opens a second popup listing profiles. Because the first TrackPopupMenuEx has not returned, the second call fails with 1446. Posting a private message and opening the profile menu after return preserves expected selection behavior.
References
Looking for a different code? Search another status or error code.
