Search code examples
c++windows-10contextmenudesktop-applicationsystem-tray

Windows 10 tray menu behind taskbar


I have an application with an icon in the system tray.
When you right click the tray icon it shows a menu where the user can select an action.
I have found that if I have a full screen application running and then use alt + esc to get to the tray icon. Then when I right click the icon the menu will show up behind(under) the windows taskbar.
In some cases, the menu is so low that it is not possible to select the lowest menu item in the context menu.
When it is not a full screen application that is in front the menu is correctly shown on top of the taskbar. I have also testes on windows 7 where it works fine with full screen application.
I have tried with different full screen application like internet explorer, Notepad++ but the same thing happens.
I can also see that there are lots of other application like “Skype for business” and “Radeon Settings” that does the same thing.
Skype for business with menu behind taskbar: enter image description here

For the build-in windows 10 applications this works better.
The Windows Time and Language parts of the system tray will show menus on top of the taskbar with the new windows 10 layout (black)
The Windows Sound and Network icons will hide the taskbar while showing a regular right click menu, but keeping the start menu open. (This however looks a bit strange)

I have tried with the NotificationIcon sample from the windows SDK but this also does not work correctly.

So the question is what is the right way to program showing tray context menu’s for windows 10?
My code looks like this.

case WM_RBUTTONDOWN:
{
    SetForegroundWindow();
    CMenu menu;
    menu.LoadMenu(ID_TRAY_MENU_SHOW_APP);
    CMenu* pPopup = menu.GetSubMenu ( 0 ) ;
    GetCursorPos ( &pt ) ;
    pPopup->TrackPopupMenu ( TPM_LEFTALIGN | TPM_RIGHTBUTTON,pt.x, pt.y, this );
}

Thanks for you help


Solution

  • It is a Windows 10 bug, that I have noticed with many applications. It is as if MS is not defining the taskbar properly. Been nearly 2 yrs with no fix... maybe in another couple.