Professional UI Solutions
Site Map   /  Register


Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » Problem with CExtPopupMenu and tray icon... Collapse All
Subject Author Date
Amir Ahmetovic Jul 16, 2007 - 8:31 AM


I’m using free version of Prof-UIS 2.70 and I have problem with themed popup menu showing on tray icon right mouse click.

Here is what I try to call when right mouse click occurs onto tray icon generated from my app:

CMenu mnuTray;
CExtPopupMenuWnd *pPopup;



pPopup = new CExtPopupMenuWnd;
pPopup->UpdateFromMenu(GetSafeHwnd(), &mnuTray, true);
pPopup->TrackPopupMenu(0, lpCursor.x, lpCursor.y);

With this written code, popup menu shows, but after I click any menu item I got Debug Assertion:
File: extpopupmenuwnd.h
Line: 2137

Any help would be appreciated!

Thanks in forward and best regards,
Amir Ahmetovic

Amir Ahmetovic Jul 18, 2007 - 11:05 AM

The code is to handle right mouse button click in app’s tray icon.

I have successfully managed to fix issue by adding SetForegroundWindow() before invoking pPopup->TrackPopupMenu(...).
To me it looks like CExtPopupMenuWnd "failed" to find Cmd receivers’ hWnd, but everything is working now.

Best Regards!

Technical Support Jul 19, 2007 - 4:49 AM

If some thread in some process tracks a popup menu (a Prof-UIS menu or a Win32 menu), the process should own the current foreground window. Otherwise the message loop of the thread that displays the menu window will not be able to handle menu events correctly.

Amir Ahmetovic Jul 17, 2007 - 6:36 AM

Hi, I would just like to note that it looks like I have managed to fix this kind of issue.
The trick was to add BringWindowToTop() before calling pPopup->TrackPopupMenu(...)

Here is sample code:

    if (lParam == WM_RBUTTONUP)

        POINT lpCursor;

        pPopup = new CExtPopupMenuWnd;
        pPopup->LoadMenu(GetSafeHwnd(), mnuTrayMenu, true, false);

        VERIFY(pPopup->TrackPopupMenu(0, lpCursor.x, lpCursor.y, 0));

I don’t know if this is right solution, but it seems to work in both Debug and Release mode (I got idea from sample code written in help)

Btw. I’ve noticed that showing popup menu within OnContextMenu() doesn’t need BringWindowToTop() to function properly.

Best Regards!

Technical Support Jul 17, 2007 - 8:02 AM

The system tray-based applications should use SetForegroundWindow() instead of BringWindowToTop().

Amir Ahmetovic Jul 16, 2007 - 1:39 PM

Sure, this is what stands in Call stack window:

> CExtPopupMenuWnd::MENUITEMDATA::GetCmdReceiver() line 2137 + 48 bytes
CExtPopupMenuWnd::_EndSequenceEx(CExtPopupMenuWnd::MENUITEMDATA & {...}) line 14013 + 8 bytes
CExtPopupMenuWnd::_OnMouseClick(unsigned int 514, CPoint {x=122 y=61}, unsigned char & 0) line 13922
CExtPopupMenuSite::_HookMouseProc(int 0, unsigned int 514, long 1237620) line 1162 + 32 bytes
USER32! 77d618f4()
USER32! 77d4ea9e()
USER32! 77d61699()
NTDLL! 7c90eae3()
CWinThread::PumpMessage() line 821 + 19 bytes
CWnd::RunModalLoop(unsigned long 4) line 3489 + 19 bytes
CExtResDlg::_DoModalImpl() line 6059 + 12 bytes
CExtResDlg::DoModal() line 6003 + 16 bytes
CBIHnetAccountApp::InitInstance() line 100 + 11 bytes
AfxWinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00151f3b, int 1) line 39 + 11 bytes
WinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00151f3b, int 1) line 30
WinMainCRTStartup() line 330 + 54 bytes
KERNEL32! 7c816fd7()

Technical Support Jul 18, 2007 - 10:55 AM

It seems the assertion problem depends on the code that handling menu commands. What exactly it performs?

Technical Support Jul 16, 2007 - 1:34 PM

Could you show us the content of the Call Stack window when the assertion failure occurs?