win11 23H2 ,right click on taskbar icon does not display popup menu content

CP-SOL/王 興龍(XingLong WANG) 0 Reputation points
2024-01-05T07:45:28.57+00:00

hi, dear friends!

When the system is upgraded from windows11 21H2 to 23H2, right-click on the App icon on the taskbar, only the framework of the menu is displayed, and the content of the menu is not displayed。

The abnormal displaying is as follows:

User's image

The normal displaying is as follows:

图片1

The code responsible for displaying of the right-click menu  is as follows

LRESULT CXtimAgentConDlg::OnTrayNotification(WPARAM wParam, LPARAM lParam)
{
	if(LOWORD(lParam) == WM_RBUTTONUP)
	{
		CMenu mnPopup;
		mnPopup.CreatePopupMenu();
		BuildPopupMenu(mnPopup);
		CPoint pos;
		::GetCursorPos(&pos);
		::SetForegroundWindow(m_hWnd); 
		::TrackPopupMenu(mnPopup.GetSafeHmenu(), 0, pos.x, pos.y, 0, m_hWnd, NULL);
		::PostMessage(m_hWnd, WM_NULL, 0, 0);
		mnPopup.DestroyMenu();
	}
	else if(LOWORD(lParam) == WM_LBUTTONDBLCLK)
	{
	}
	return 0L;
}

BOOL CXtimAgentConDlg::BuildPopupMenu(CMenu& mnMenu) 
{ 
	//	g_Log.Write(_T("=== CXtimAgentConDlg::BuildPopupMenu start ===")); 	
	static const PCTSTR sc_pszarTrayMenuTitles[] =  	{ 	
		  _T("MailCheck") 		, _T("ConfirmMessage") 		, _T("ConfirmSurvey") 		, _T("ModifyUserInfo") 		, _T("ManualDownload") 		, _T("WindowsUpdate") 		, _T("HelpDesk") 		, _T("RegUSB") 		, _T("PowerManage") 		, _T("SendMail") 		, _T("ShowPolicyStatus") 		, _T("QueryServerAddr") 		, _T("ShowVersionInfo") 		, _T("ShowInventory") 		, _T("ConnectToServer") 
		}; 
	static const UINT sc_puiarTrayMenuResIds[] =  	{ 		
	40000, 40001, 40002, 40003, 40004, 40005, 40006, 40007, 40008, 40009, 40010, 40011, 40012, 40013, 40014 	}; 	g_Log.Write(_T("Create the popup menu for Tray Icon"));   
	int nItemCnt = sizeof(sc_puiarTrayMenuResIds) / sizeof(UINT);
	CRegKey regKey; 
	CString szTrayKey; 
try 
{ 		
	szTrayKey.Format(_T("%s\\TrayMenu"), XTIM_REG_PATH); 	
	if(ERROR_SUCCESS == regKey.Open(HKEY_LOCAL_MACHINE, szTrayKey, KEY_READ))
	{ 
		int nMenuIndex = 0; 		
		int nSeparator = 0; 		
		for(int i=0; i<nItemCnt; i++) 			
		{ 		
			DWORD dwValue = 0; 			
			if(ERROR_SUCCESS != regKey.QueryDWORDValue(sc_pszarTrayMenuTitles[i], dwValue)) 		
			{ 				
				g_Log.Write(_T("The specified %s registry key doesn't exist."),sc_pszarTrayMenuTitles[i]); 	
				dwValue = 0; 				
			} 			
			if(dwValue == 0) 	
				continue;  			
			nMenuIndex ++;  		
			CString szMenuName; 
			UINT uFlags = MF_STRING;  
			szMenuName.LoadString(IDS_MI_MAILCHECK + (sc_puiarTrayMenuResIds[i] - IDM_TRAY_CMD_START)); 
			if( (sc_puiarTrayMenuResIds[i] == IDM_TRAY_DOWNLOAD && !m_bEnableMD) ||  						(sc_puiarTrayMenuResIds[i] == IDM_TRAY_CNT2SVR  && !m_bEnableCS) ) 		
				uFlags |= (MF_DISABLED|MF_GRAYED); 			
	 		else 				
				uFlags |= MF_ENABLED;  				//add by daiyg for mailcheck 2015-12-29 Begin 			
			if ((sc_puiarTrayMenuResIds[i] == IDM_TRAY_MAILCHECK)) 			
			{ 				
				uFlags = MF_POPUP; 			
				mnMenu.AppendMenu(uFlags, (UINT)mnMenu.m_hMenu, szMenuName);  	
				uFlags = MF_STRING; 	
		  		 if (theApp.IsMailCheckAlive()) 				
			   		uFlags |= MF_ENABLED; 					
		   		else 					
	        		uFlags |= (MF_DISABLED|MF_GRAYED);  				
				//获取1级菜单 				
				CMenu* pMailCheckMenu=mnMenu.GetSubMenu(0); 		
				//添加2级菜单 					
				if(pMailCheckMenu->GetSafeHmenu()==NULL)  				
					continue; 					
				szMenuName.LoadString(IDS_MI_MAIL_CONFIRM); 			
				pMailCheckMenu->AppendMenu(uFlags,IDM_TRAY_CONFIRM,szMenuName); 
				szMenuName.LoadString(IDS_MI_MAIL_SETTING); 
				pMailCheckMenu->AppendMenu(uFlags,IDM_TRAY_SETTING,szMenuName);	 
			}//add by daiyg for mailcheck 2015-12-29 End 		
			else if ((sc_puiarTrayMenuResIds[i] == IDM_TRAY_USBLOGIN)) 
			{ 					
				uFlags = MF_POPUP; 		
				mnMenu.AppendMenu(uFlags, (UINT)mnMenu.m_hMenu, szMenuName);  		
				uFlags = MF_STRING; 				
				uFlags |= MF_ENABLED;  					//获取1级菜单 		
				CMenu* pMailCheckMenu=mnMenu.GetSubMenu(nMenuIndex-1); 					//添加2级菜单 			
				if(pMailCheckMenu->GetSafeHmenu()==NULL)  			
	  				continue; 					
				szMenuName.LoadString(IDS_MI_REG_USB); 		
				pMailCheckMenu->AppendMenu(uFlags,IDM_TRAY_REGUSB,szMenuName); 
				szMenuName.LoadString(IDS_MI_WORKFLOW_INFO); 					
				pMailCheckMenu->AppendMenu(uFlags,IDM_TRAY_WORKFLOW,szMenuName); 			
			} 				
			else if ((sc_puiarTrayMenuResIds[i] == IDM_TRAY_POWERMANAGE)) 	
			{ 				
				if (IsPowerManageEnabled()) 		
				{ 					
					uFlags = MF_POPUP; 			
					mnMenu.AppendMenu(uFlags, (UINT)mnMenu.m_hMenu, szMenuName);  		
					uFlags = MF_STRING;  				
					CMenu* pMailCheckMenu=mnMenu.GetSubMenu(nMenuIndex-1); 						//添加2级菜单 	
					if(pMailCheckMenu->GetSafeHmenu()==NULL) 
	 							continue; 					
					szMenuName.LoadString(IDS_MI_POWEROFF_SCHEDULE); 
					pMailCheckMenu->AppendMenu(uFlags,IDM_TRAY_POWEROFF,szMenuName); 
					szMenuName.LoadString(IDS_MI_OVERTIME_APPROVED); 
					pMailCheckMenu->AppendMenu(uFlags,IDM_TRAY_OVERTIME,szMenuName); 
				} 				
			} 				
			else  				
				mnMenu.AppendMenu(uFlags, sc_puiarTrayMenuResIds[i], szMenuName); 		
			nSeparator++; 			
			if(	sc_puiarTrayMenuResIds[i] == IDM_TRAY_MAIL || sc_puiarTrayMenuResIds[i] == IDM_TRAY_VERSION) 
			{ 				
				mnMenu.AppendMenu(MF_SEPARATOR | MF_BYPOSITION, nSeparator); 				
				nSeparator++; 			
			} 		
		} 		
	} 		
	else 		
	{ 		
		g_Log.Write(_T("The specified TrayMenu registry key cann't read.")); 	
	} 	
} 	
catch(HRESULT e) 	
{ 		
	g_Log.Write(XEX_SRCINFO,HR_LAST_ERR);
} 
catch(...) 
{ 		
	g_Log.Write(XEX_SRCINFO,HR_LAST_ERR); 
} 
//	g_Log.Write(_T("=== CXtimAgentConDlg::BuildPopupMenu end ===")); 
return TRUE; 
} 


Windows for business | Windows Client for IT Pros | User experience | Other
Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
{count} votes

1 answer

Sort by: Most helpful
  1. S.Sengupta 27,596 Reputation points MVP
    2024-01-08T01:08:44.45+00:00
    • Open Command Prompt as administrator (search for "cmd" and right-click "Run as administrator").
    • Type sfc /scannow and press Enter.
    • Wait for the scan to complete and restart your PC.
    • If issues persist, run DISM /Online /Cleanup-Image /RestoreHealth and restart again.
    • Create a new User Account to recheck the issue.
    • If required, you need to reinstall Windows11.
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.