Combobox in menu bar? |
Post Reply |
Author | |
brianh
Groupie Joined: 30 April 2004 Location: United Kingdom Status: Offline Points: 83 |
Post Options
Thanks(0)
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
|
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
Yes
|
|
brianh
Groupie Joined: 30 April 2004 Location: United Kingdom Status: Offline Points: 83 |
Post Options
Thanks(0)
|
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. |
|
SunIron
Newbie Joined: 18 March 2008 Status: Offline Points: 4 |
Post Options
Thanks(0)
|
try this example
\Codejock Software\MFC\Xtreme ToolkitPro v11.2.2\Samples\CommandBars\DynamicPopups\ |
|
Onur
Groupie Joined: 17 August 2005 Status: Offline Points: 37 |
Post Options
Thanks(0)
|
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 |
|
steven123
Newbie Joined: 09 October 2009 Status: Offline Points: 4 |
Post Options
Thanks(0)
|
Hi brianh, i have the same question to you. But i have not figured out it. Can you share you idea with? thank you .
|
|
brianh
Groupie Joined: 30 April 2004 Location: United Kingdom Status: Offline Points: 83 |
Post Options
Thanks(0)
|
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
|
|
steven123
Newbie Joined: 09 October 2009 Status: Offline Points: 4 |
Post Options
Thanks(0)
|
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 .
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |