Professional UI Solutions
Site Map   /  Register
 
 

Forum

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 » the check mark in popup menu Collapse All
Subject Author Date
Michael chang Feb 18, 2009 - 12:44 AM

Hi.


I would like to check(mark) in popup menu which is based on CExtPopupMenuWnd.


I have tried to check in CMainframe But it doesn’t check.


///////


CMainframe::OnUpdate****(CCmdUI *pCmdUI)


{


          pCmdUI->SetCheck(1);


}


///////


 


How to check in popup menu?

Michael chang Feb 23, 2009 - 7:24 PM

Menu bar is ok. it works fine.


but, context menu is not working properly.


the more in datail is the below.


1. Create Popup menu


   CMenu menu;

   if(menu.GetSafeHmenu() == NULL )

   {

    if( !menu.LoadMenu(IDR_MENU_POPUP) )

    {

     ASSERT( FALSE );

     return;

    }

   }


   CExtPopupMenuWnd * pPopup = new CExtPopupMenuWnd;

   pPopup->UpdateFromMenu(GetSafeHwnd(), &menu, true, true, true);


//


   if (!pPopup->TrackPopupMenu(TPMX_OWNERDRAW_FIXED, point.x, point.y))

   {

    delete pPopup;

   }


//


2. Message map



CMainframe::OnUpdateAAA(CCmdUI *pCmdUI)

{

          pCmdUI->SetCheck(1);

}


CMainframe::OnAAA()

{


          pCmdUI->SetCheck(1);


}


 


thanks.



 

Technical Support Feb 24, 2009 - 1:14 PM

The problem is hidden in the following line of code:

pPopup->UpdateFromMenu(GetSafeHwnd(), &menu, true, true, true);

If you replace it with the following line of code:
pPopup->UpdateFromMenu(GetSafeHwnd(), &menu, true, true, false);

Then all the menu command items in this context menu will be updated via standard MFC’s command manager mechanism.

Technical Support Feb 19, 2009 - 4:01 AM

The menu item does not become checked if the command updating handler method is not invoked for it (probably you forgot to insert a message map entry or bound it to an incorrect command identifier). Please let us know more details about your menu. Is it menu bar’s menu or context menu? If it’s context menu, then how did you construct it?