if(!LoadToolBar(IDR_MYTOOL))
return -1;
CClientDC dc(this);
m_font.CreatePointFont (80, _T ("MS Sans Serif"));
CFont* pOldFont = dc.SelectObject (&m_font);
TEXTMETRIC tm;
dc.GetTextMetrics(&tm);
dc.SelectObject(pOldFont);
// TODO: Add your specialized creation code here
SetButtonInfo(0, IDC_MYTOOL, TBBS_SEPARATOR, tm.tmAveCharWidth*30);
CRect rect;
GetItemRect(0, &rect);
rect.bottom = rect.top + ((tm.tmHeight + tm.tmExternalLeading)*16);
if(!m_wndCombo.Create(WS_CHILD | WS_VISIBLE | WS_VSCROLL | CBS_SORT | CBS_DROPDOWNLIST,
rect, this, IDC_MYTOOL))
return -1;
m_wndCombo.SetFont(&m_font);
m_wndCombo.AddString(_T("ONE"));
m_wndCombo.AddString(_T("TWO"));
m_wndCombo.AddString(_T("THREE"));
m_wndCombo.AddString(_T("FOUR"));
m_wndCombo.AddString(_T("FIVE"));
m_wndCombo.SetCurSel(0);
Controls in Toolbars : MFC
Hi,
I'm trying to place other controls besides buttons inside a toolbar. My first attempt at making it work was somewhat successful but I'm still not satisfied with it. Here is the code inside my inheritted toolbar:
My toolbar resource at first consisted of just one "dummy" button at index 0 which I replaced with my combobox. The result was that the combobox would not show up and the toolbars' height was only a few pixels. I spent forever going over my code to see if maybe I was forgetting to set a value or call some specific function that would change the height but couldn't find anything. Finally, out of curiosity I added a regular toolbar button at index 1 and it all of a sudden worked. I was able to see my combobox and interact with it.
This is not want I'm eventually aiming for, rather, I don't want ANY toolbar buttons in my toolbar for a project I'm trying to do. Basically, what I'm going to be doing is creating a tabbed control that offers context specific variables for the user to modify. Any help on how I can make it work without a default button in the toolbar would be greatly appreciated.
thanks
[edited by - xtrmntr on April 25, 2002 7:49:34 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement