简体   繁体   中英

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: 在此处输入图片说明

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

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.

This one did the trick for me in W10 when experiencing the same issue with the tray menu of catalyst control center:

  • Unlock taskbar
  • Move it to any other side of the desktop
  • Lock and Unlock taskbar
  • Place taskbar back to your preferred position and lock it

Maybe it's a client issue and not related to your code at all.

Source: http://www.thewindowsclub.com/fix-windows-7-start-menu-hides-behind-the-taskbar

I can confirm, that this seems to be a Windows bug which occurs randomly on my Windows 10 instance. It seems to happen when waking windows up from sleep after I docked or undocked my notebook from a docking station, where I use a different monitor setup. But it's hard to tell if this is the cause or not.

If it happens, I run a batch script with following content:

taskkill /F /IM explorer.exe
# Wait a few seconds
ping -n 3 127.0.0.1 > NUL 2>&1
start explorer.exe

This restarts Windows Explorer and all the tray menus start appearing in front of the task bar again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM