Print Page | Close Window

Combobox in menu bar?

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=9668
Printed Date: 01 February 2025 at 8:04am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Combobox in menu bar?
Posted By: brianh
Subject: Combobox in menu bar?
Date Posted: 22 February 2008 at 10:31am
Hi, is it possible to add a combobox to the menu bar as a top level item, preferably on the far right hand side away from the other menu items?
 
Thanks.
 
Brian



Replies:
Posted By: SuperMario
Date Posted: 22 February 2008 at 11:44am
Yes




Posted By: brianh
Date Posted: 25 February 2008 at 8:24am

I can't find any sample projects that have a combo in the menu bar (as shown in your bitmap), but it doesn't matter, I figured out how to do it myself.

Thanks.


Posted By: SunIron
Date Posted: 27 March 2008 at 9:24am
try this example
\Codejock Software\MFC\Xtreme ToolkitPro v11.2.2\Samples\CommandBars\DynamicPopups\


Posted By: Onur
Date Posted: 01 June 2008 at 1:06am
Hello, is there a sample for ActiveX?
I'm not using MFC..


-------------
Product: Xtreme SuitePro (ActiveX) version 12.0.1
Platform: Windows XP (32bit) - SP 2
Language: Visual C# .NET


Posted By: steven123
Date Posted: 16 October 2009 at 3:39am
Originally posted by brianh brianh wrote:

I can't find any sample projects that have a combo in the menu bar (as shown in your bitmap), but it doesn't matter, I figured out how to do it myself.

Thanks.
 
Hi brianh, i have the same question to you. But i have not figured out it. Can you share you idea with? thank you .


Posted By: brianh
Date Posted: 19 October 2009 at 4:31am

Hi steven123, I used the following code to add a combo to the r/h side of the menu bar:

CXTPCommandBars* pCommandBars = GetCommandBars() ;

CXTPMenuBar* pMenuBar = pCommandBars->GetMenuBar() ;

// now add combo control to r/h side of menu

CXTPControls* pCtrls = pMenuBar->GetControls() ;

ASSERT( NULL == pCtrls->FindControl(ID_MYCOMBO) ) ; // should NOT already exist!

CXTPControlComboBox* pMyCB = (CXTPControlComboBox*)pCtrls->Add( xtpControlComboBox, ID_MYCOMBO, NULL, -1, TRUE ) ;

pMyCB->SetCaption(_T("My Combo"));

pMyCB->SetWidth(180);

pMyCB->SetDropDownListStyle( FALSE ) ; // dropdown list mode (no edit)

pMyCB->SetFlags( xtpFlagManualUpdate | xtpFlagNoMovable | xtpFlagRightAlign ) ;

In my case I need to switch menus on the fly so I placed this code where I switch the menus, but I expect you will probably want to put it in OnCreate() or wherever you initialize the command bars.
 
NB: The last parameter to the CXTPControls::Add() method call is bTemporary, which I have set to TRUE, but I can't remember what this actually does, so you may need to experiment with it or check out the source code to see if you need to set it differently.
 
I don't know if this is the recommended method to use, but it works for me. :) 
 
brian


Posted By: steven123
Date Posted: 21 October 2009 at 10:53pm

Hi brianh, first of all , thanks for you share of the idea.

yes, as you said  i have figured out the how to add a control in right-side  of  the command bar.
Just by adding a menu item at the end of the main meunbar, and set it's ID like ID_MYCOMBO, I initialize the menubar in mainframe.cpp:
 
int CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl)
{
    ......
   

if(lpCreateControl->nID == ID_MYCOMBO)

{

CXTPControlComboBox* pComboBox = new CXTPControlComboBox();

pComboBox ->SetDropDownListStyle(TRUE);

pComboBox ->SetWidth(180);

pComboBox ->SetID(ID_MYCOMBO);

pComboBox ->SetFlags(xtpFlagManualUpdate | xtpFlagRightAlign);

pComboBox ->SetEditHint(_T("some strings"));

lpCreateControl->pControl = pComboBox ;

return TRUE;

}

.............
}
 I needn't  to switch menus on the fly .
 



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