Click here to Skip to main content
Click here to Skip to main content

How to place controls on toolbars

By , 12 Jan 2000
 

It is very easy (once you see how it is done) to place combo-boxes, edit boxes, progress controls, etc. into toolbars. Below are two examples of this, in the first a ComboBox is placed on a toolbar, and in the second a cluster of checkboxes is added. In both cases the technique is the same:

Step 1: Place a button on the toolbar in the spot where you want the control(s) to eventually be. YOU MUST place a seperator on either side of the button!. Give the button an easily remembered resource name such as IDP_PLACEHOLDER2 in the example below.

Step 2: Derive a class from CToolBar and give it a member variable for the control you will be creating. For the ComboBox example that class looks like this. No extra methods are required, just a place for the instance of the control to live.

class CMainToolBar : public CToolBar 
{
public:
    CComboBox m_wndSnap;
};

Step 3: In your main frame's .h file replace the instance of the CToolBar with you new class. Be sure to add an include statement for the class definition created in step 1.

protected: // control bar embedded members
    CStatusBar m_wndStatusBar;
    CMainToolBar m_wndToolBar;

Step 4: At the end of your main frame's OnCreate method you replace the placeholder button with your control as follows:

int SMCMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    /////////////////////////////////////////
    //Body of On Create goes here

    #define SNAP_WIDTH 80 //the width of the combo box

    //set up the ComboBox control as a snap mode select box
    //
    //First get the index of the placeholder's position in the toolbar
    index = 0;
    while (m_wndToolBar.GetItemID(index) != IDP_PLACEHOLDER2) index++;

    //next convert that button to a seperator and get its position
    m_wndToolBar.SetButtonInfo(index, IDP_PLACEHOLDER2, TBBS_SEPARATOR,
        SNAP_WIDTH);
    m_wndToolBar.GetItemRect(index, &rect);

    //expand the rectangle to allow the combo box room to drop down
    rect.top+=2;
    rect.bottom += 200;

    // then .Create the combo box and show it
    if (!m_wndToolBar.m_wndSnap.Create(WS_CHILD|WS_VISIBLE|CBS_AUTOHSCROLL| 
                                       CBS_DROPDOWNLIST|CBS_HASSTRINGS,
                                       rect, &m_wndToolBar, IDC_SNAP_COMBO))
    {
        TRACE0("Failed to create combo-box\n");
        return FALSE;
    }
    m_wndToolBar.m_wndSnap.ShowWindow(SW_SHOW);

    //fill the combo box
    m_wndToolBar.m_wndSnap.AddString("SNAP OFF");
    m_wndToolBar.m_wndSnap.AddString("SNAP GRID");
    m_wndToolBar.m_wndSnap.AddString("SNAP RASTER");
    m_wndToolBar.m_wndSnap.AddString("SNAP VERTEX");
    m_wndToolBar.m_wndSnap.AddString("SNAP LINE");
    m_wndToolBar.m_wndSnap.SetCurSel(0);
}

The result looks like this:

Here is one that is a little trickier:

Four check boxes are placed in the toolbar. In addition to adding multiple controls in place of a single button this example shows how to change the font of the checkboxes.

1. Derive the new toolbar class and add it to the main frame. Also add a CFont called gSmallFont to the Main Frame.

class CCoupleToolBar : public CToolBar
{
public:
    CButton m_wndCenter;
    CButton m_wndEdge;
    CButton m_wndTrack;
    CButton m_wndZoom;
};

2. Place a placeholder button on the toolbar resource MAKING SURE to leave a space on either side. This is done just as in the first example.

3. At the end of OnCreate in the main frame, first set up the font we are going to use, then replace the placeholder button with the new controls.

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    ////////////////////////////////
    // Body of OnCreate here
    
    //set up the small font to use for the button text
    // remember to declare CFont gSmallFont in the .h file
    // font for tool bar use
    CClientDC DC(GetDesktopWindow());
    long logical_pixels = DC.GetDeviceCaps(LOGPIXELSX);
    if(logical_pixels <100)

    {
        gSmallFont.CreatePointFont(67, "DEFAULT", NULL);  
    }    
    else 
    {   
        gSmallFont.CreatePointFont(50, "DEFAULT", NULL); 
    }   
    
    //create the four check boxes  
    #define CHECK_WIDTH 94  
    int index;   
    CRect rect;   
    CRect safe_rect;
    index = 0;  
     
    while (m_wndViewBar.GetItemID(index) != IDP_PLACHOLDER) index++;     
    
    // Create the "CENTER" check box   
    m_wndViewBar.SetButtonInfo(index, IDP_PLACHOLDER, TBBS_SEPARATOR,
        CHECK_WIDTH); 
    m_wndViewBar.GetItemRect(index, &rect); 
    safe_rect=rect;    
    rect.left +=2;   
    rect.right=rect.left + ((CHECK_WIDTH / 2)-4);   
    rect.top=2;

    rect.bottom=rect.top + 10;   
    if (!m_wndViewBar.m_wndCenter.Create("CNTR",
        BS_CHECKBOX|WS_CHILD|WS_VISIBLE, rect, &m_wndViewBar,
        IDM_COUPLE)) 
    { 
        TRACE0("Failed to create CENTER check-box\n");       
        return FALSE;    
    }    
    m_wndViewBar.m_wndCenter.SendMessage(WM_SETFONT,
        (WPARAM)HFONT(gSmallFont),TRUE);  
    rect.top = rect.bottom += 2;   
    rect.bottom = rect.top + 10;    
    if (!m_wndViewBar.m_wndEdge.Create("EDGE",
        BS_CHECKBOX|WS_CHILD|WS_VISIBLE, rect, &m_wndViewBar,
        IDM_COUPLE_EDGE))
    {         
        TRACE0("Failed to create EDGE check-box\n");        
        return FALSE; 
    }    
    m_wndViewBar.m_wndEdge.SendMessage(WM_SETFONT,
        (WPARAM)HFONT(gSmallFont), TRUE);
    rect = safe_rect;
    rect.left += ((CHECK_WIDTH / 2) + 4);   
    rect.top = 2;

    rect.bottom = rect.top + 10; 
    if (!m_wndViewBar.m_wndZoom.Create("ZOOM",
        BS_CHECKBOX|WS_CHILD|WS_VISIBLE, rect, &m_wndViewBar,
        IDM_LOCK_ZOOMS))
    {      
        TRACE0("Failed to create ZOOM check-box\n");    
        return FALSE;   
    }    
    m_wndViewBar.m_wndZoom.SendMessage(WM_SETFONT,
        (WPARAM)HFONT(gSmallFont),TRUE);   
    rect.top = rect.bottom += 2;   
    rect.bottom = rect.top + 10;  
    if (!m_wndViewBar.m_wndTrack.Create("TRKR",
        BS_CHECKBOX|WS_CHILD|WS_VISIBLE, rect, &m_wndViewBar,
        IDM_SHOW_TRACKING))  
    {       
        TRACE0("Failed to create EDGE check-box\n");    
        return FALSE;   
    }   
    m_wndViewBar.m_wndTrack.SendMessage(WM_SETFONT,
        (WPARAM)HFONT(gSmallFont), TRUE); 
} 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Randy More
United States United States
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionHow does this works on a splitter frame toolbar?memberfdkhb4 Jan '09 - 15:20 
Sir,
I generate a splitter wnd and attach a frame with toolbar. When run application with your code, it breaks at:
 
if (!m_wndToolBar.m_SelThresCombo.Create(WS_CHILD|WS_VISIBLE | CBS_AUTOHSCROLL |
CBS_DROPDOWNLIST |
CBS_HASSTRINGS ,
rect, &m_wndToolBar,
IDP_PLACECONTROL2))
 
BOOL CComboBox::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
UINT nID)
{
CWnd* pWnd = this;
Frown | :( return pWnd->Create(_T("COMBOBOX"), NULL, dwStyle, rect, pParentWnd, nID);
}
 
And error info is:
 
Unhandled exception in XXX.exe (MFC420D.dll):0xC0000005: Access Violation
 
early wait for your help.
Thanks!
Questionm_wndToolBar.m_wndSnap.Create(......)?memberbonmeepon26 Feb '06 - 19:29 
Check the following codes.
CComboBox m_wndSnap;
CMainToolBar m_wndToolBar;
 
and then,
m_wndToolBar.m_wndSnap.Create(......)
 
Because m_wndToolBar belongs to CMainToolBar class and m_wndSnap belongs to CComboBox, why does m_wndToolBar.m_wndSnap work?
 
bonmeepon means pupcorn
GeneralHandling returnmemberviaduct3 Oct '05 - 5:17 
Hi,
 
I'm trying to catch the user pressing return so I can implement a search on the entered text, but I cannot find where this keypress goes - neither OnChar, OnSelendok or any other function seem to receive this message!
 
Help! Smile | :)

GeneralDraw on Toolbar buttonmemberAnything.J24 Mar '05 - 23:57 
I have a toolbar on SDI frame. I am able to add the buttons onto the toolbar at run time. I want to draw line or draw rect on that buttons. I don't want to insert a BMP into it.Can anybody let me know how I can draw line or draw rect on that buttons at run time. Thank you in advance!!!

GeneralFont In Combobox In Toolbarmemberkoorosh7 Jan '05 - 22:33 
Hi Dear Friend.
I have Problem in changing Font of Combobox .
could u please help me?
 
i have added this codes before AddString("");
 
but the font has not changed.
 
CWnd *dcCwnd = CWnd::FromHandle(m_wndToolBar.m_wndSnap.m_hWnd);
CDC *dc = dcCwnd->GetDC();
CFont font;
VERIFY(font.CreatePointFont(120, "Arial", dc));
 
// Do something with the font just created...
CFont* def_font = dc->SelectObject(&font);
dc->TextOut(5, 5, "Hello", 5);
dc->SelectObject(def_font);
 
// Done with the font. Delete the font object.
font.DeleteObject();
 
thanks allot
 
Koorosh Nosrati Heravi
GeneralHandle to the MENUmemberAlex Evans16 Nov '04 - 13:22 
Hello
 
I have a toolbar that one of the buttons has a drop-down / floating menu (the dialog of CFileDialog for example) - how can I get a handle to that menu?
 
Thanks
Alex
GeneralThat looks familiar...memberAnna-Jayne Metcalfe16 Apr '04 - 3:49 
Aren't those screenshots from the GUI for the Morrow VXIbus spectrum analyser?
 
Until 1998 I worked for Racal Instruments. I actually wrote a virtual instrument driver for that beast for use in one of our ATE systems.
 
Small world. Roll eyes | :rolleyes:
 
Anna Rose | [Rose]
 
Homepage | Tears and Laughter
 
"Be yourself - not what others think you should be"
- Marcia Graesch
 
"Anna's just a sexy-looking lesbian tart"
- A friend, trying to wind me up. It didn't work.
 
Trouble with resource IDs? Try the Resource ID Organiser Visual C++ Add-In

GeneralCatching Messages from CViewmemberJay Jonna Jameson31 Mar '04 - 9:38 
Randy,
 
How would one use your method of imbeding controls in a toolbar and catching events from those controls (Like a dropdown combobox 'CBN_SELCHANGE')?
 
Thanks for any info you can provide.
 

GeneralRe: Catching Messages from CViewmember*Dreamz2 Apr '04 - 2:20 
Hi,
In the View class .h File, delcare the message map function.
//{{AFX_MSG(CControlToolBarView)
afx_msg void OnSelchangeCombo();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()

Link the function to the corresponding ID in view .cpp file.
BEGIN_MESSAGE_MAP(CControlToolBarView, CView)
   //{{AFX_MSG_MAP(CControlToolBarView)
   ON_CBN_SELCHANGE(IDC_SNAP_COMBO, OnSelchangeCombo)
   //}}AFX_MSG_MAP
END_MESSAGE_MAP()

Define the function in View .cpp file.
void  CControlToolBarView::OnSelchangeCombo()
{
   //Your code goes here 
}
I have tried this from the code that is created by the MFC App wizard for an event.Think this will help you.
 
Regards

GeneralRe: Catching Messages from CViewmemberBig Eyes, Small Head2 Apr '04 - 6:00 
Perfect. Thanks
Generalthe &quot;little&quot; ComboBoxsussCynicannibal29 Oct '03 - 23:55 
Hi,
 
I tryed your way to put a ComboBox in a Toolbar, it works well, except that the ComboBox isn't the same as you !!!
It's a big, flat ComboBox.
How can I do to have the same little ComboBox as on the pic ?
 
Thanks
Phil
GeneralCatch IndexsussThim7 Oct '03 - 2:41 

First of all, excuse my english
 
I have a suggestion for you.
Why no to try this piece of code :

int index = m_wndToolBar.CommandToIndex(IDP_PLACEHOLDER2); 

rather than :
int index = 0;  
while (m_wndToolBar.GetItemID(index) != IDP_PLACEHOLDER2) index++; 

to get the index of the placeholder.
 

Best regards

 
Thim;P


GeneralRe: Catch IndexmemberThim7 Oct '03 - 4:06 
Me again.
 
#define statements
in the body of the code isn't very convenient.
 
I like your pedagogy nevertheless
 

 
Thim
QuestionWhy can't I place a CStatic on the toolbar?memberHighersong5 Jun '03 - 0:28 
I have placed CCombox and CEdit,but it does not work when i place a CStatic!!!Confused | :confused:

AnswerRe: Why can't I place a CStatic on the toolbar?memberBrendan Tregear6 Aug '03 - 15:41 
Hmm, it worked for me, here's the function I created in my custom toolbar:
 
BOOL CSearchToolBar::CreateStatic(CStatic& txtStatic,
CString strText,
UINT nIndex,
UINT nID,
int nWidth)
{
// Create the combo box
SetButtonInfo(nIndex, nID, TBBS_SEPARATOR, nWidth);
 
CRect rect;
GetItemRect(nIndex, &rect);
rect.top = 1;
 
if (!txtStatic.Create(strText, WS_VISIBLE, rect, this, nID))
{
TRACE("Failed to create static window...\n");
return FALSE;
}

return TRUE;
}

GeneralRe: Why can't I place a CStatic on the toolbar?membervikas amin28 Sep '05 - 23:05 
thanks that solves even my problem
to display an image in toolbar
 
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
QuestionHow to Catch Event from the VB ActiveX Control from ToolBar ?memberDominicOn1 May '03 - 10:39 
I placed an User Control successfully to the toolbar. But how do I catch the event fired from the control ? Please help.
 
Thanks in advance.

 
Dominic
GeneralMenu on toolbarmemberCSZX3 Apr '02 - 22:49 
How can I place a menu on a toolbar?Confused | :confused:
 
CSZX
QuestionHow to use Drop Down Arrow to show a wnd, just as what the arrow by Undo-button does in Visual Studio?membermsvcna26 Mar '02 - 16:46 
When we use Visual Studio to develop our project,we ofen use the Drop-Down Arrow by the Undo-button to show a window and select more than one steps to undo.I want to
do such a window and tried a lot,but failed.Please give me a solution to show how to make such a window using MFC.
Thanks.
GeneralResizing Embedded ControlsmemberMarcus Carey21 Mar '02 - 14:06 
There are numerous examples on creating an IE style coolbar but they do not show how to create the address band which as a combo box and tool button.
 
Although you can embed a combo box in a toolbar control it does not resize when moved to a new location in the ReBar.
 

 
Marcus Carey
Generalset focus & lost focusmemberpiyer19 Mar '02 - 21:56 

Hello thanks for the codes. It helped me a lot.
I still have a problem. I wanted to add an event using tab keys.
I have an SDI application. It has a tree view and a list view (like an windows explorer - windows 95 ).
 
When i press the tab key, i wanted to change the focus ( from the treeview to the listview, from the listview to the combo control, from the combo control back to the treeview ).
 
I could already change focus from treeview to listview, and listview to combo control. But when changing focus from combo control to treeview i'm not getting the focus of the treeview, it keeps on returning to the combo control. Can you help me with this?
 
I have attached my codes for changing the focus
 
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
if( (pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_TAB) )
{
switch( g_intFlag )
{
case 0 :
{
g_bListViewActivated = TRUE;
 
// set focus to list view
GetRightPane( )->OnActivateView( 1, GetRightPane( ), GetLeftPane( ) );
g_intFlag = 1;
break;
}
 
case 1 :
{
g_bComboActivated = TRUE;
 
// set focus to combo box
m_wndCombo.SetFocus( );
g_intFlag = 2;
break;
}
 
case 2 :
{
g_bTreeViewActivated = TRUE;
g_bXComboActivated = TRUE;
 
// set focus to tree view
GetLeftPane( )->OnActivateView( 1, GetLeftPane( ), GetRightPane( ) );
g_intFlag = 0;
break;
}
 
} // end case
 
} // end if
 
return CFrameWnd::PreTranslateMessage(pMsg);
}
 
Also is there any way i could force an object. Like an combo control to lost its focus.
 
Thanks and more power.
 
Big Grin | :-D
 
piyer
GeneralCapturing data from ComboBoxmemberStew2 Jan '02 - 5:30 
How do I handle the capturing of the data in these ToolBar Combo Boxes? I want to handle it the same way it would be done if these comboboxes were in a dialogbar or something like that. I also want to be able to send a message to my application when the item in the combo box is changed. Any thoughts?
 
One other thing, the combo box doesn't show all of the possible choices in it. It will scroll itself down when the user selects an item that is low on the list as it will display that item as the first item in the list, but when that happens, I can't get to any of the items above that selection. I'm just wondering how to get a scrollbar in the combobox.
GeneralWondering what I'm doing wrongmemberStew1 Jan '02 - 16:50 
I'm getting an error at the following line of code:
 
while (m_wndToolBar.GetItemID(index) != IDP_PLACEHOLDER2) index++;
 
I'm not sure what I'm missing. I must have missed something in the OnCreate before this line of code, but I'm not sure what it is. I created the Toolbar class that I'm using and declared the two CComboBox members. I'm just not uerstanding how to get everything working together.
 
Thoughts?
GeneralRe: Wondering what I'm doing wrongmemberAnonymous28 Jun '02 - 14:43 
You need to call LoadToolBar(ToolBarID);
Generalsome code to enable checkboxesmemberAydin Bakir6 Dec '01 - 3:13 

I had to add few codes to make the checkboxes look "enabled" because they looked "DISABLED."
 
m_wndToolBar.m_wndCenter.SetButtonStyle( BS_AUTOCHECKBOX );
m_wndToolBar.m_wndEdge.SetButtonStyle( BS_AUTOCHECKBOX );
m_wndToolBar.m_wndTrack.SetButtonStyle( BS_AUTOCHECKBOX );
m_wndToolBar.m_wndZoom.SetButtonStyle( BS_AUTOCHECKBOX );

GeneralWhen toolbar is too small...memberVale30 Oct '01 - 4:11 
I created a toolbar in wich I add buttons dinamically. When the number of buttons rise over a certain number or when I resize the browser window, ALL OF THE BUTTONS disappear. I have two questions:
- Have you got any idea on why they disappear all at a time and not one at a time (depending on how much I resize the window)?
- How can I do to put the buttons in excess in a popup at the end of the toolbar? Is this a property of the toolbar itself or do I have to manage it manually?
Thanks in advance
 
Vale
GeneralCustom-colored buttons on a toolbarmemberAmir Kibar10 Oct '01 - 1:54 
Hi,
 
I want to create a toolbar that has custom colored buttons. the purpose of this is to create a color-chooser for a paint-like application. I need some "standard" colors (red, blue, green, black, white, etc.) and one button for "custom" color that the user will choose with a standard color chooser.
 
the question is - how do I change the color of the buttons on a toolbar?
 
Thanks
GeneralNeed to add button to default toolbar in WinSDKmemberAshley Pinto8 Oct '01 - 6:41 
Hi,
I have an Outlook Add-in and have to add a button for displaying one of my dialogs in Outlook. I also need to implement the clicking of the button and displaying of my dialog. This Add-in is written using win32 SDK.
I haven't started it and need ideas (couldn't find any).
Thanks in Advance
Ashley
GeneralToolbar without C++memberNovacain2 Aug '01 - 21:50 
I use DevStudio and don't use the MFC, ie Visual C (no ++) or Win32 API.
Can you get a resizing toolbar without the classes?
Any I create do not change size if the window changes or the monitors resolution changes.
I also need to put other controls apart from buttons but one step at a time.

GeneralTooltipsmemberJean-Yves26 Dec '00 - 21:21 
Hi,
 
When using your code to inserty combobox in a toolbar, we cannot have tooltips on the combobar. I don't understand why (i set the style of the toolbar to CBRS_TOOLTIPS, and it doesn't work !!).
Anybody has an idea ??
 
Thanks
 
Jean-Yves
GeneralRe: TooltipsmemberUma Mahes28 Oct '03 - 19:50 
Hi Jean,
 
Am also facing similar kind of problem ,not able to see tooltips on a combobox.If you know any solution to this problem please let me know
 
Thanks
 
Uma
GeneralRe: TooltipssussDenisZ4 Nov '03 - 2:10 
This is because placeholder's style is changed to separator. Separators doesn't produce tooltip notification massages.
GeneralOver and oversussAlexander27 Jul '00 - 1:50 
Nothing new. Absolutely. Look at CTRLBARS example in MSDN.
I can't help wondering why some people still post articles
while more informative ones can easily be found in MSDN Lib..
GeneralRe: Over and oversussUser27 Jul '00 - 1:59 
And waht are you contributing? My mother always said that if you don't have anything nice to say about someone then don't say anything at all. So I won't say anything about YOU
GeneralRe: Over and oversussAlexander27 Jul '00 - 3:15 
Look around, dear User, how many articles with NEW ideas
can one find on this site? Too few, and it disappoints.
Most contributors receive 4.1-4.8 for their
articles and almost no negative comments. One can post
MS VS addon which almost ruines resource file in a project.
It wasn't merely thought through. This one was not rated below 4. Yes, some comments improved it much, but nobody said "Hey, did you ever tried it by yourself?". And that's the common tendency Frown | :(
 
I thought that this site was destined for sharing ideas,
not for rising self-esteem. I didn't mean to offend anybody.
 
Criticism is very stimulating thing, IMHO. But slightly more
hurting than coffee :
GeneralRe: Over and overmemberShyguy from China6 Nov '00 - 20:38 
You are right Alex,The Problem you mentioned above are much more serious than here in chinese bbs site. Any guy will be considered as a skilled programmer in chinese bbs if he can read the articles here and translate it into chinse and post it.
Like me heeeheeeWink | ;-) .
GeneralRe: Over and overmemberMember #408077827 Jan '08 - 18:08 
????????????????,???????
?MSDN????????
???????,???????
????????,?????,???????????????
?????????
This is like me read English.
GeneralRe: Over and overmemberMember #408077827 Jan '08 - 18:14 
Don't display Chinese!
Why my programme have to support English. Cry | :((
GeneralRe: Over and oversussDave R17 Aug '00 - 4:32 
I have to agree with Alex. What is the point in posting a rehash of information that is better presented in MSDN? This doesn't help anyone. I came to this site in hopes of finding something truly informative. Instead all I did was waste time.
 
The editors of this site do no-one any favors by posting redundant material. It's a nice looking site and all, but I would be more impressed with a plain text format that actually taught me something.
 
And as for snide rejoinders, I have posted articles elsewhere that I thought filled in missing gaps. I tried not to waste my own time and that of others by posting something I'd already seen elsewhere
GeneralRe: Over and oversussAndy Metcalfe11 Oct '00 - 1:31 
It may be "nothing new", but consider this:
 
The site can and should contain content for developers of ALL skill levels. It also acts as a central point for developers, grouping related techniques and samples together - something which MSDN often totally fails to do.
 
As such it is perfectly valid for articles describing and expanding on techniques also addressed in the VC/MSDN documentation to be posted on the site.
 
If this were not the case, why bother including tutorials?
 
If you're unhappy with the content of the site you should either try to contribute in a CONSTRUCTIVE manner or don't comment at all. You always have the option of not looking at it if the content annoys you that much
GeneralRe: Over and overmemberRay Romero22 Nov '00 - 7:13 
I totally agree with you, I am new to windows programming and I come here for help and only look for the subject matter that I need help on.
GeneralEXACTLY! GOT IT GUYS! :)memberMasoud Samimi30 Dec '00 - 9:43 
Andy! Hi,
 
2 thumbs up for you and who ever support you! Big Grin | :-D ( if I could borrow more thumbs I would raise as well for Randy and the Article!
 
And as for you guys who don't contribute; if YOU use, then it is your will to APPRECIATE! But in terms of MANNERS, I GUESS YOU SHOULD! Wink | ;)
 
Others who just comment such as the ones here; think before you leap! You might end up fallen in a ditch somwhere, someday!
 
No hard feelings though! It is BEST FOR YOU!
 
All you, Have a wonderfull New Year 2001 and many many returns of the happiest and most desired days! Smile | :)
 
Hasta Manana y Feliz Nuevo Ano!
 
"Silence is golden, but my eyes still see."
-- Masoud Samimi
Website: www.geocities.com/samimi73

GeneralRe: Over and overmembercypherljk30 Dec '00 - 7:27 
I agree and disagree with your statement. Although the article may be on MSDN who the hell can find it! Almost every search will bring you at least 100 hits of which the 1st 20 are probably not what your looking for. In your defense tis article could have been a bit more detailed. The creation of the toolbar itself is not shown the author should have tried it themselves. I do think it an ok article.
 
Eek! | :eek:
 
To err is human, therefore I must not be human.
GeneralRe: Over and overmemberWarren Gardner10 Jul '01 - 10:21 
Actually this article was quite new to me. After wasting a lot of time searching MSDN,
I took a look at the codeproject site. I found Randy's solution immediately, and after
reading your response I also built the CTRLBARS example.
 
Thanks to Randy for saving me a lot of time!
And thanks to Alexander for pointing me to the CTRLBARS example
(but lose the Mad | :mad: attitude Alexander).

QuestionWhat about edit/spin combinations?sussRob Edwards9 Jun '00 - 10:13 
How can i add an edit box with a spinner buddy to the toolbar?

AnswerRe: What about edit/spin combinations?memberMasoud Samimi27 Dec '00 - 0:56 
Hi,
 
See if this one meets what you want! Smile | :)
 
http://www.codeproject.com/docking/spnsld.asp
 
Enjoy! Smile | :)
 
" I love water, but hate to drown! "
-- Masoud Samimi
Website: www.geocities.com/samimi73

GeneralCombo font - too largesussFrédéric Marion-Poll5 Mar '00 - 11:57 
Your suggestion on how to add combos or other windows to a toolbar is great. In my application however, the font displayed by the combo box is large - I guess it is using the system font. The buttons however are using a much smalled font.
 
I tried to use the approach you outline for adding 4 check boxes instead, and this works fine to adjust the combo font. I had to fiddle with the font size to have something that looks like the font used by the toolbar buttons.
 
Is there a more direct way to pick up the font used by the buttons and to apply it to the combo?
 
sincerely
fre
GeneralRe: Combo font - too largesussRichard Odenweller4 Apr '00 - 7:23 
Try using this after creating your control.
 
myControl.SetFont(myToolbar.GetFont());
 
This method doesn't require you to create a fon
GeneralRe: Combo font - too largememberAdam Bialowas18 Aug '01 - 10:20 

Ha! Love it!
 
Simple trick, but its nice and neat!
 
Thanks!
 
Adam Bialowas
GeneralRe: Combo font - too largememberdrhender27 Jun '02 - 5:33 
It's been a long time since the question was asked, but I'll post a response for the benefit of others...
 
You can set the font on any CWn by calling the SetFont( &font ) method.   To get ahold of the default GUI font from the OS, call CreateStockObject(DEFAULT_GUI_FONT), which creates a CFont for you equivalent to what the rest of windows is using.   Dont forget to delete the object when you are done.
 
   CFont font;
   font.CreateStockObject(DEFAULT_GUI_FONT) );
   m_cmboZoom.SetFont( &font );
   font.DeleteObject();
 
Hope that helps...

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 13 Jan 2000
Article Copyright 2000 by Randy More
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid