Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Tear off menu
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Tear off menu

 Post Reply Post Reply
Author
Message
DavidH View Drop Down
Groupie
Groupie


Joined: 24 March 2007
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote DavidH Quote  Post ReplyReply Direct Link To This Post Topic: Tear off menu
    Posted: 19 November 2009 at 11:22am
What is the best way to get rid of the Toolbar Options menu in a tear off menu.

The problem is that the toolbar holding the menu is created only when the menu is teared off, and that there's no real hook to use to disable it.

So I've tried to derive from CXTPPopupBar and call:
    m_pTearOffBar->ShowExpandButton(FALSE);
    m_pTearOffBar->SetContextMenuPresent(FALSE);
    m_pTearOffBar->EnableCustomization(FALSE);

but this only results in CJ drawing the Expand button not in the title bar, but at the bottom of the window.

I've also tried to to put an ON_UPDATE_COMMAND_UI on XTP_ID_TOOLBAR_EXPAND, and make the the control invisible, but the code is not reached for some reason. I guess the message is handled at a higher level.

I'm sort of lost now.

All help is very much appreciated!

David.
Back to Top
DavidH View Drop Down
Groupie
Groupie


Joined: 24 March 2007
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote DavidH Quote  Post ReplyReply Direct Link To This Post Posted: 19 November 2009 at 3:42pm
Well, it seems that I've solved it myself.

To get to the tear-off menu, add

  ON_XTP_CREATECOMMANDBAR()

to the MESSAGE_MAP of CMainFrame.


Then, add the following method:

int
CMainFrame::OnCreateCommandBar(LPCREATEBARSTRUCT lpCreateBar) {
  if (lpCreateBar->nID == ID_TEAR_OFF_MENU) {
    CXTPToolBar* pTearOffMenu((CXTPToolBar*)lpCreateBar->pCommandBar);
    if (pTearOffMenu) {
      pTearOffMenu->EnableCustomization(FALSE);
      pTearOffMenu->ShowExpandButton(FALSE);
      return TRUE;
    }
  }
  return FALSE;
}

Very simple, really, but it took me a day to figure it out :(

David.

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.