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 » How to cancel a popup menu? Collapse All
Subject Author Date
George Freewood Aug 3, 2007 - 7:37 AM

Hello,

we want to create a toolbar button with some kind of associated drop down menu. But instead of displaying the normal CExtPopupMenuWnd we need to display a custom popup window, when the drop down arrow of the toolbar button is being clicked.

For this reason we are trying to disable the CExtPopupMenuWnd, while still leaving the drop down arrow in the tool bar button be enabled.

We looked into your source code and detected, that setting the flag CExtPopupMenuWnd::MsgPrepareMenuData_t::m_bMenuCanceled to true may work here.

Indeed this almost seems exactly to do, what we want to do - with one problem: ProfUIS crashes due to a duplicate call to the destructor of the CExtPopupMenuWnd object.

Is this the intended result, when somebody sets this flag?

Technical Support Aug 3, 2007 - 10:33 AM

You should use the toolbar button class listed below. What you should only do is to put your own popup window tracking code into it:

class CYourButton : public CExtBarButton
{
public:
      DECLARE_DYNCREATE( CYourButton );
      CYourButton(
            CExtToolControlBar * pBar = NULL,
            UINT nCmdID = ID_SEPARATOR,
            UINT nStyle = 0
            )
            : CExtBarButton( pBar, nCmdID, nStyle )
      {
      }
      virtual ~CYourButton()
      {
      }
      virtual bool IsAbleToTrackMenu(
            bool bCustomizeMode = false
            ) const
      {
            ASSERT_VALID( this );
            if( bCustomizeMode )
                  return false;
            return true;
      }
      virtual UINT OnTrackPopup(
            CPoint point,
            bool bSelectAny,
            bool bForceNoAnimation
            )
      {
            . . .
      }
};
You can use the CExtBarColorButton::OnTrackPopup() method’s source code as an example.

George Freewood Aug 3, 2007 - 11:07 AM

Hello,

I was already afraid, that this is your answer. This solution is very long-winded and rather static, because it requires creation of an own toolbar class and creation of an own button class at all places, where such feature is desired.

Wouldn’t it be much simpler, more dynamic and more generic, if each popup menu could be cancelled at any time at runtime by simply setting a bit in the CExtPopupMenuWnd::g_nMsgPrepareMenu message handler? As I mentioned in my previous article this bit is already there in Prof-UIS. What about simply making this bit working without leading the application to crash?

Technical Support Aug 6, 2007 - 8:01 AM

We do not agree that the solution is long winded. When a pop-up menu is open and then you set the mouse pointer over some other button with pop-up menu (e.g. in the menu bar), the pop-up menu will be closed and the new pop-up menu appears.So the Prof-UIS pop-up works in conjunction with drop-down buttons and it is not enough just to cancel the Prof-UIS pop-up menu and show your own one.