Simon Pettman
March 30th, 1999, 10:35 AM
I have managed to add a Static control and a ComboBox to the control.
However when I try and add a third control. As spin control the control the ToolBar goes all thin and only really
properly docks at the sides of the parent.
Does anyone have any clues as to why this would occur. I dont think it has anything to do do with the the fact it is a
CSpinCtrl, because the problem occurs at the "SetButtonInfo" stage
Simon Pettman
_____________example OnCreate() in Main Frame.________________________
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.Create(this) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndToolBar2.Create(this,WS_CHILD|WS_VISIBLE|CBRS_TOP,IDR_FREQ_TOOL) ||
!m_wndToolBar2.LoadToolBar(IDR_FREQ_TOOL))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
CRect rect;
int index=0;
while(m_wndToolBar2.GetItemID(index)!=ID_FREQ_TOOL_STATIC)
index++;
m_wndToolBar2.SetButtonInfo(index,ID_FREQ_TOOL_STATIC,
TBBS_SEPARATOR,100);
m_wndToolBar2.GetItemRect(index,&rect);
rect.top+=4;
m_wndToolBar2.m_staticFreq.Create("Frequency",WS_CHILD|
WS_VISIBLE|SS_RIGHT,rect,
(CWnd*) &m_wndToolBar2,ID_FREQ_TOOL_STATIC);
index=0;
while(m_wndToolBar2.GetItemID(index)!=ID_FREQ_TOOL_COMBO)
index++;
m_wndToolBar2.SetButtonInfo(index,ID_FREQ_TOOL_COMBO,
TBBS_SEPARATOR,250);
m_wndToolBar2.GetItemRect(index,&rect);
// rect.top+=4;
m_wndToolBar2.m_comboFreq.Create(WS_CHILD|
WS_VISIBLE|SS_RIGHT,rect,
(CWnd*) &m_wndToolBar2,ID_FREQ_TOOL_COMBO);
index=0;
while(m_wndToolBar2.GetItemID(index)!=ID_FREQ_TOOL_SPIN)
index++;
m_wndToolBar2.SetButtonInfo(index,ID_FREQ_TOOL_SPIN,
TBBS_SEPARATOR,400);
m_wndToolBar2.GetItemRect(index,&rect);
m_wndToolBar2.m_spinFreq.Create(WS_CHILD|
WS_VISIBLE|SS_RIGHT,rect,
(CWnd*) &m_wndToolBar2,ID_FREQ_TOOL_SPIN);
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
m_wndStatusBar.SetPaneInfo(0,ID_SEPARATOR,SBPS_STRETCH,200);
// TODO: Remove this if you don't want tool tips or a resizeable toolbar
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_wndToolBar.SetBarStyle(m_wndToolBar2.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBar2.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
DockControlBar(&m_wndToolBar2,AFX_IDW_DOCKBAR_TOP);
return 0;
}
________________________________________________________________
The first two controls are fine.
However when I try and add a third control. As spin control the control the ToolBar goes all thin and only really
properly docks at the sides of the parent.
Does anyone have any clues as to why this would occur. I dont think it has anything to do do with the the fact it is a
CSpinCtrl, because the problem occurs at the "SetButtonInfo" stage
Simon Pettman
_____________example OnCreate() in Main Frame.________________________
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.Create(this) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndToolBar2.Create(this,WS_CHILD|WS_VISIBLE|CBRS_TOP,IDR_FREQ_TOOL) ||
!m_wndToolBar2.LoadToolBar(IDR_FREQ_TOOL))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
CRect rect;
int index=0;
while(m_wndToolBar2.GetItemID(index)!=ID_FREQ_TOOL_STATIC)
index++;
m_wndToolBar2.SetButtonInfo(index,ID_FREQ_TOOL_STATIC,
TBBS_SEPARATOR,100);
m_wndToolBar2.GetItemRect(index,&rect);
rect.top+=4;
m_wndToolBar2.m_staticFreq.Create("Frequency",WS_CHILD|
WS_VISIBLE|SS_RIGHT,rect,
(CWnd*) &m_wndToolBar2,ID_FREQ_TOOL_STATIC);
index=0;
while(m_wndToolBar2.GetItemID(index)!=ID_FREQ_TOOL_COMBO)
index++;
m_wndToolBar2.SetButtonInfo(index,ID_FREQ_TOOL_COMBO,
TBBS_SEPARATOR,250);
m_wndToolBar2.GetItemRect(index,&rect);
// rect.top+=4;
m_wndToolBar2.m_comboFreq.Create(WS_CHILD|
WS_VISIBLE|SS_RIGHT,rect,
(CWnd*) &m_wndToolBar2,ID_FREQ_TOOL_COMBO);
index=0;
while(m_wndToolBar2.GetItemID(index)!=ID_FREQ_TOOL_SPIN)
index++;
m_wndToolBar2.SetButtonInfo(index,ID_FREQ_TOOL_SPIN,
TBBS_SEPARATOR,400);
m_wndToolBar2.GetItemRect(index,&rect);
m_wndToolBar2.m_spinFreq.Create(WS_CHILD|
WS_VISIBLE|SS_RIGHT,rect,
(CWnd*) &m_wndToolBar2,ID_FREQ_TOOL_SPIN);
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
m_wndStatusBar.SetPaneInfo(0,ID_SEPARATOR,SBPS_STRETCH,200);
// TODO: Remove this if you don't want tool tips or a resizeable toolbar
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_wndToolBar.SetBarStyle(m_wndToolBar2.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBar2.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
DockControlBar(&m_wndToolBar2,AFX_IDW_DOCKBAR_TOP);
return 0;
}
________________________________________________________________
The first two controls are fine.