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 Tech Support » PopupMenu question Collapse All
Subject Author Date
tera tera Dec 26, 2009 - 1:10 AM

Hello.


Cannot you build such PoupMenu?


Technical Support Jan 6, 2010 - 9:18 AM

Check marks can be set on/off through the CCmdUI::SetCheck() method invoked in the command updating handler method.

tera tera Jan 8, 2010 - 5:23 PM

Because the following menus cannot set ID.

I cannot use CCmdUI-SetCheck.


 


Technical Support Jan 11, 2010 - 5:16 AM

Yes. This is right. You should use dynamic menu construction:

http://www.prof-uis.com/prof-uis/tech-support/faq/pop-up-menus.aspx#how-to-insert-menu-items-at-run-time

You can use the CExtPopupMenuWnd::ItemGetInfo() to get the CExtPopupMenuWnd::MENUITEMDATA data structure describing the popup menu item and set its checked state using the CExtPopupMenuWnd::MENUITEMDATA::Check() method.

tera tera Jan 13, 2010 - 1:24 AM


I click this place and want to judge it.

Is it impossible?

Technical Support Jan 13, 2010 - 11:09 AM

You should catch the CExtPopupBaseWnd::g_nMsgTranslateMouseClickEvent registered message. The WPARAM parameter is pointer to the CExtPopupBaseWnd::TranslateMouseClickEventData_t data structure. You should set its m_bMessageHandled property to true flag value if your handler method processes the mouse click event.
The CExtPopupMenuWnd::_HitTest() internal method can be used for hit testing the menu elements. If the returned value is greater or equal to zero, then it specifies the menu item index. If it’s negative, then you should use the following enumeration declared locally in the CExtPopupMenuWnd class:

   enum spec_buttons_index_t
            {
                        IDX_NOTHING = -1,
                        IDX_SCROLL_TOP = -2,
                        IDX_SCROLL_BOTTOM = -3,
                        IDX_EXPAND = -4,
                        IDX_TEAROFF = -5,
                        IDX_RIBBON_FILE_MENU_OPTIONS_BUTTON = -6,
                        IDX_RIBBON_FILE_MENU_EXIT_BUTTON = -7,
            };

tera tera Jan 13, 2010 - 6:43 PM

 


Popup is not closed even if I click it.

I want to close Popup.

Please teach a method.


LRESULT CSamplePopupDlg::OnTranslateMouseClickEvent(WPARAM wParam, LPARAM lParam) {  wParam;    CExtPopupBaseWnd::TranslateMouseClickEventData_t * pData =   reinterpret_cast< CExtPopupBaseWnd::TranslateMouseClickEventData_t  * >   ( wParam );

 pData->m_bMessageHandled = true;  CMuPopupMenuWnd * pPopupMenuWnd = (CMuPopupMenuWnd *)pData->m_pEventSourcePopup;  int nIndex = pPopupMenuWnd->_HitTest( pData->m_point );

 return false; }

Technical Support Jan 15, 2010 - 8:13 AM

The CExtPopupMenuWnd::_ItemFocusCancel() method closes the next level popup menu.

tera tera Jan 15, 2010 - 6:55 PM

I programed it as follows

PopupMenu does not close it




 



LRESULT CSamplePopupDlg::OnTranslateMouseClickEvent(WPARAM wParam, LPARAM lParam) {  wParam;    CExtPopupBaseWnd::TranslateMouseClickEventData_t * pData =   reinterpret_cast< CExtPopupBaseWnd::TranslateMouseClickEventData_t  * >   ( wParam );

 pData->m_bMessageHandled = true;  CMuPopupMenuWnd * pPopupMenuWnd = (CMuPopupMenuWnd *)pData->m_pEventSourcePopup;  int nIndex = pPopupMenuWnd->_HitTest( pData->m_point );

 pPopupMenuWnd->_ItemFocusCancel( TRUE , TRUE , TRUE );

 return false; }

 

 

Technical Support Jan 17, 2010 - 10:56 AM

Here is the fixed source code:

            lParam;
CExtPopupBaseWnd::TranslateMouseClickEventData_t * pData =
                        reinterpret_cast< CExtPopupBaseWnd::TranslateMouseClickEventData_t  * >
                        ( wParam );
CExtPopupMenuWnd * pPopupMenuWnd = (CExtPopupMenuWnd*)pData->m_pEventSourcePopup;
            // the pData->m_point point depends on WM_*** or WM_NC*** message type
            // we will get actual cursor position instead
CPoint ptHitTest;
            if( ! ::GetCursorPos( &ptHitTest ) )
                        return 0L;
            pPopupMenuWnd->ScreenToClient( &ptHitTest );
int nIndex = pPopupMenuWnd->_HitTest( ptHitTest );
            if( nIndex >= 0 )
            {
                        CExtPopupMenuWnd::MENUITEMDATA & mi = pPopupMenuWnd->ItemGetInfo( nIndex );
                        if( mi.IsPopup() )
                        {
                                    // close displayed sub menu, un-focus menu item
                                    pPopupMenuWnd->_ItemFocusCancel( FALSE, TRUE, FALSE );
                                    // restore menu item focus, do not show next level submenu
                                    pPopupMenuWnd->_ItemFocusSet( nIndex, FALSE, TRUE, FALSE, FALSE );
                                    // move captured state into clicked popup menu
                                    pPopupMenuWnd->_SetCapture();
                                    pData->m_bMessageHandled = true; // we handled this message
                                    pData->m_bNoEat = false; // this message should be filtered by thread hook of popup menu
                        }
            }
            return 0L;

tera tera Jan 17, 2010 - 6:07 PM

Hello.


The program does not work well.

Popup is not closed even if I click it.

I prepared a sample.

You click Button1, and please display PopupMenu.


http://ifreeta.dee.cc/20100118/SamplePopup2.lzh



 


 

tera tera Jan 19, 2010 - 5:30 PM

 


I never request this function.

However, is it impossible to realize this function?


 

Technical Support Jan 20, 2010 - 1:31 PM

We tested the suggested code in the ProfUIS_Controls sample application. We modified the CPagePopupMenus dialog page. Here is the updated code files:

http://www.prof-uis.com/download/forums/tmp/MenuTestForTeraTera.zip

Please extract the PagePopupMenus.h and PagePopupMenus.cpp files from this ZIP file into the folder of the ProfUIS_Controls sample application, then compile and run it. You can right click the Popup Menus dialog page and context menu and context menu will appear. This context menu contains several popup items and they behave like you requested.

tera tera Jan 14, 2010 - 6:17 PM

 


Is it impossible?

I give it up. ( It does not need to be able to come true forcibly. )


Thanks

Technical Support Dec 26, 2009 - 12:36 PM

We suspect your question is related to popup menus displayed from ribbon buttons because all your last questions were related to ribbon bar. Please let us assume you already initialized some CExtRibbonNode which represents a button in your ribbon bar. This button is displayed and works as an normal push button in your ribbon bar. To make it displaying a popup menu like on your screen shot you should construct the CExtCustomizeCmdTreeNode-based tree representing the popup menu. The menu must contain only the CExtCustomizeCmdTreeNode objects. It must not contain the CExtRibbonNode objects. I.e. if you already initialized the CExtRibbonNode node representing ribbon button, then you should insert the CExtCustomizeCmdTreeNode nodes into button’s ribbon node and these CExtCustomizeCmdTreeNode nodes will represent the first level of popup menu. Some of CExtCustomizeCmdTreeNode objects can contain a set of CExtCustomizeCmdTreeNode nodes representing the second menu level.

tera tera Jan 4, 2010 - 5:58 PM

 


>We suspect your question is related to popup menus displayed from ribbon buttons because all your last questions were related to ribbon bar

 

No, the ribbon menu does not matter.

In normal PopupMenu,

I want PopupMenu which can realize the following checkmarks.





I want a sample.

Is this unrealizable?