int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } //////////////////////////////////////////////////////////////////// CImageList img; if(!img.Create(IDB_MAINFRAME,20,10,RGB(255,0,0))) { TRACE0("Failed to load hot images\n"); return -1; } m_wndToolBar.GetToolBarCtrl().SetHotImageList(&img); img.Detach();
m_wndToolBar.ModifyStyle(0,TBSTYLE_FLAT);
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 }
for(int i = 0; i < m_wndToolBar.GetCount(); i++) { UINT id = m_wndToolBar.GetItemID(i); CString s; if(!s.LoadString(id)) continue; int j = s.Find(_T('\n')); if(j < 0) continue; s = s.Right(s.GetLength() - j - 1); m_wndToolBar.SetButtonText(i,s); }// Adjust sizes to include text CRect rect; m_wndToolBar.GetItemRect(0,&rect); m_wndToolBar.SetSizes(rect.Size(),CSize(20,20));
// TODO: Delete these three lines if you don't want the toolbar to // be dockable m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
////////////////////////////////////////////////////////////////////
CImageList img;
if(!img.Create(IDB_MAINFRAME,20,10,RGB(255,0,0)))
{
TRACE0("Failed to load hot images\n");
return -1;
}
m_wndToolBar.GetToolBarCtrl().SetHotImageList(&img);
img.Detach();
m_wndToolBar.ModifyStyle(0,TBSTYLE_FLAT);
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
}
for(int i = 0; i < m_wndToolBar.GetCount(); i++)
{
UINT id = m_wndToolBar.GetItemID(i);
CString s;
if(!s.LoadString(id)) continue;
int j = s.Find(_T('\n'));
if(j < 0) continue;
s = s.Right(s.GetLength() - j - 1);
m_wndToolBar.SetButtonText(i,s);
}// Adjust sizes to include text
CRect rect;
m_wndToolBar.GetItemRect(0,&rect);
m_wndToolBar.SetSizes(rect.Size(),CSize(20,20));
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
}