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

Combobox in menu bar?

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


Joined: 30 April 2004
Location: United Kingdom
Status: Offline
Points: 83
Post Options Post Options   Thanks (0) Thanks(0)   Quote brianh Quote  Post ReplyReply Direct Link To This Post Topic: Combobox in menu bar?
    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
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 22 February 2008 at 11:44am
Yes


Back to Top
brianh View Drop Down
Groupie
Groupie


Joined: 30 April 2004
Location: United Kingdom
Status: Offline
Points: 83
Post Options Post Options   Thanks (0) Thanks(0)   Quote brianh Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
SunIron View Drop Down
Newbie
Newbie
Avatar

Joined: 18 March 2008
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote SunIron Quote  Post ReplyReply Direct Link To This Post Posted: 27 March 2008 at 9:24am
try this example
\Codejock Software\MFC\Xtreme ToolkitPro v11.2.2\Samples\CommandBars\DynamicPopups\
Back to Top
Onur View Drop Down
Groupie
Groupie


Joined: 17 August 2005
Status: Offline
Points: 37
Post Options Post Options   Thanks (0) Thanks(0)   Quote Onur Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
steven123 View Drop Down
Newbie
Newbie


Joined: 09 October 2009
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote steven123 Quote  Post ReplyReply Direct Link To This Post 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 .
Back to Top
brianh View Drop Down
Groupie
Groupie


Joined: 30 April 2004
Location: United Kingdom
Status: Offline
Points: 83
Post Options Post Options   Thanks (0) Thanks(0)   Quote brianh Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
steven123 View Drop Down
Newbie
Newbie


Joined: 09 October 2009
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote steven123 Quote  Post ReplyReply Direct Link To This Post 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 .
 
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.047 seconds.