Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 451
  • Last Modified:

How to insert controls into CToolBar?

How to insert controls (like CComboBox) into CToolBar?
Now I'm inserting CComboBox calling CComboBox::Create(), but I can't insert buttons after CComboBox.
0
Nightmare090197
Asked:
Nightmare090197
  • 2
1 Solution
 
Nightmare090197Author Commented:
Edited text of question
0
 
snoeglerCommented:
Use a CDialogBar. CToolBar is just for buttons.
0
 
migelCommented:
to add control into CToolBar you must perform two steps:
1.in ToolBar resource define 3 separators/per control
[]___[][][] ([]- button _ separator) control will appear after first button) two additional separators are for create free space between buttons and control.
2.when you create toolbar just resize appropriate separator and place control into separators rectangle:
// typically this code is placed in the CMainFrame::OnCreate function
// IDW_COMBO - identifier of the combobox
// m_wndToolBar - your CToollBar
//
//

// this code must be called after createion m_wndToolBar
// Create the combo box
m_wndTollBar.SetButtonInfo(2, IDW_COMBO, TBBS_SEPARATOR, 100);

CRect rect;
m_wndStyleBar.GetItemRect(2, &rect);
rect.top = 3;
rect.bottom = rect.top + 100;
if (!m_wndComboBox.Create(CBS_DROPDOWNLIST|WS_VISIBLE|WS_TABSTOP,
                  rect, &m_wndToolBar, IDW_COMBO))
{
      TRACE0("Failed to create combo-box\n");
      return FALSE;
}



0
 
migelCommented:
oops.. sorry
m_wndToolBar.GetItemRect(2, &rect);
2 - index of the toolbar item
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now