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 » Pop-up menu in TreeView Collapse All
Subject Author Date
joce joce Oct 17, 2003 - 5:12 AM

Hello,
I would like to create a specifique pop-up menu in my TreeView regarding the item which is selected. To do so I ve created a function called OnExtMenuPrepare.

//
ON_REGISTERED_MESSAGE(CExtPopupMenuWnd::g_nMsgPrepareMenu,OnExtMenuPrepare)

//

In this function I get the pop-up pointeur back and I modify it :

CGCSISUtilisateurDoc* pDoc = (CGCSISUtilisateurDoc*)GetDocument();

CExtPopupMenuWnd::MsgPrepareMenuData_t * pData = reinterpret_cast<CExtPopupMenuWnd::MsgPrepareMenuData_t*>(wParam);
ASSERT(pData!=NULL);

CExtPopupMenuWnd* pPopup = pData->m_pPopup;
ASSERT(pPopup!=NULL);

VERIFY(pPopup->LoadMenu(m_hWnd,IDR_POP_MENU_ARBRE_UTILISATEUR));

UINT basicCommands[] =
{
    ID__AU_NOUVEAU,
    ID__AU_MODIFIER,
    ID__AU_SUPPRIMER,
    0,
};
g_CmdManager->SetBasicCommands(g_CmdManager->ProfileNameFromWnd(GetSafeHwnd()),basicCommands,true);

VERIFY(g_CmdManager->CmdSetIcon(g_CmdManager->ProfileNameFromWnd(GetSafeHwnd()),ID__AU_NOUVEAU,pDoc->m_icoNouveau,false));
VERIFY(g_CmdManager->CmdSetIcon(g_CmdManager->ProfileNameFromWnd(GetSafeHwnd()),ID__AU_MODIFIER,pDoc->m_icoNouveau,false));
VERIFY(g_CmdManager->CmdSetIcon(g_CmdManager->ProfileNameFromWnd(GetSafeHwnd()),ID__AU_SUPPRIMER,pDoc->m_icoNouveau,false));

By doing this, I manage to have my menu, but if try to open a menu in the main frame I lost the old menus and I ve the new one everywhere.

However, if I click on a view that does not support OnExtMenuPrepare, all my menus come back to normal.

So how can I create a specifique menu in my TreeView that does not modify the others menu ?????

Thanks.

Sergiy Lavrynenko Oct 17, 2003 - 8:15 AM

Hi,

First problem is in the command manager initialization code (which is usually in CMainFrame::OnCreate()). Please put SetBasicCommands(), CmdSetIcon() and g_CmdManager->UpdateFromMenu(...,IDR_POP_MENU_ARBRE_UTILISATEUR) into CMainFrame::OnCreate() like any Prof-UIS frame-based sample does.

Second problem is related to CExtPopupMenu::LoadMenu() usage. This method creates new menu. It can not be used with popup menu in MsgPrepareMenuData_t. Please load standard CMenu and then invoke CExtPopupMenu::UpdateFromMenu(GetSafeHwnd(),CMenu*,true,false).

If the problem persists, please send me your project and I will help you.