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 » How to add ComboBox to popup(context) menu? Collapse All
Subject Author Date
Viktor Korol Mar 7, 2008 - 11:12 AM

Is it possible to add a combo box in a context menu in such a way as it is added to the main menu in the sample "StyleEditor" (http://www.prof-uis.com/FeatureTour.aspx?view=tour_menu_edit_fields)?
If it’s possible, please provide an example of how this is implementing.

Thanks in advance.

Technical Support Mar 8, 2008 - 11:18 AM

The combo boxes in the StyleEditor sample are not combo box common controls. They are built in items of Prof-UIS customization subsystem. The StyleEditorsample initializes common description for the font combo box in the CMainFrame::OnCreate() method:

      pCmdItem = g_CmdManager->CmdGetPtr( pApp->m_pszProfileName, ID_SE_FONT_LIST );
      pCmdItem->StateSetCombo();
      pCmdItem->StateSetResizable();
      pCmdItem->m_nTextFieldWidth = pCmdItem->m_nDropDownWidth = 150;
Then the customization subsystem initializes combo fields for the ID_SE_FONT_LIST command in toolbars and menus instead of default toolbar command buttons and menu command items. If you are using customizable toolbars and menus, then you can use the approach implemented in the Microsoft Office and Visual Studio applications: You can create one additional toolbar and use it’s buttons as context menus. This toolbar should be visible in the customize mode to let user customize context menus. This toolbar should be invisible in normal mode. So, you should set its CExtControlBar::m_bAppearInDockSiteControlBarPopupMenu property to false. This will hide menu command of this toolbar in all the built-in Prof-UIS menus. Then you should create it as initially invisible. You should also implement the CExtCustomizeSite::OnCustomizeModeEnter() and CExtCustomizeSite::OnCustomizeModeLeave() virtual methods which should make the context menus toolbar force visible when the customize mode begins and hide it on end. If you need to show context menu, then you should get the command tree node of appropriate toolbar button, construct the newly allocated CExtPopupMenuWnd from it using the CExtPopupMenuWnd::UpdateFromCmdTree() method.

If you are not using the customization subsystem, then you will need to initialize the combo box in popup menu manually and implement callbacks for it. You should insert normal command item first and get the CExtPopupMenuWnd::MENUITEMDATA & menu item description for it using the CExtPopupMenuWnd::ItemGetInfo() method. The CExtPopupMenuWnd::MENUITEMDATA::SetInplaceEdit() method converts the command button into text field button. But if you will insert the CExtPopupListBoxMenuWnd popup list box sub menu instead of the command menu first using the CExtPopupMenuWnd::ItemInsertSpecPopup() method, then the converted to edit popup menu sub item will look and work like combo box. The CExtPopupListBoxMenuWnd class also requires its special callback functions for implementing popup list box functionality.

The approach based on customizable toolbars and menus is better because you don’t need to implement any callbacks. You need to override only the CExtCustomizeSite::OnTextField***() and CExtCustomizeSite::OnPopupListBox***() required virtual methods instead.