Print Page | Close Window

Tear off menu

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=15664
Printed Date: 08 July 2024 at 5:39pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Tear off menu
Posted By: DavidH
Subject: Tear off menu
Date 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.



Replies:
Posted By: DavidH
Date 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.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net