1.在OnCreate中
if (!m_wndToolBar.CreateEx(this ,TBSTYLE_FLAT, WS_CHILD | |WS_VISIBLE | CBRS_TOP
| CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndChildToolBar.CreateEx(this,TBSTYLE_FLAT,WS_CHILD | WS_VISIBLE
| CBRS_TOOLTIPS|CBRS_TOP|CBRS_FLYBY|CBRS_GRIPPER) ||
!m_wndChildToolBar.LoadToolBar(IDR_TOOLBAR_LAD))
{
TRACE0("Failed to create childtoolbar\n");
return -1; // fail to create
}
2.if (!m_comToolBar.CreateEx(this, 0 , WS_CHILD
| WS_VISIBLE | CBRS_LEFT| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY
| CBRS_SIZE_FIXED) ||
!m_comToolBar.LoadToolBar(IDR_TOOLBAR_COM))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
} // TODO: Delete these three lines if you don't want the toolbar to
// be dockable
RECT rect;
rect.top=0;rect.bottom=500;rect.left=0;rect.right=50; m_comToolBar.GetToolBarCtrl().SetExtendedStyle(TBSTYLE_WRAPABLE);
m_comToolBar.GetToolBarCtrl().SetRows(9,TRUE,&rect);
m_comToolBar.SetHeight(60);
if (!m_wndToolBar.CreateEx(this ,TBSTYLE_FLAT, WS_CHILD | |WS_VISIBLE | CBRS_TOP
| CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndChildToolBar.CreateEx(this,TBSTYLE_FLAT,WS_CHILD | WS_VISIBLE
| CBRS_TOOLTIPS|CBRS_TOP|CBRS_FLYBY|CBRS_GRIPPER) ||
!m_wndChildToolBar.LoadToolBar(IDR_TOOLBAR_LAD))
{
TRACE0("Failed to create childtoolbar\n");
return -1; // fail to create
}
2.if (!m_comToolBar.CreateEx(this, 0 , WS_CHILD
| WS_VISIBLE | CBRS_LEFT| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY
| CBRS_SIZE_FIXED) ||
!m_comToolBar.LoadToolBar(IDR_TOOLBAR_COM))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
} // TODO: Delete these three lines if you don't want the toolbar to
// be dockable
RECT rect;
rect.top=0;rect.bottom=500;rect.left=0;rect.right=50; m_comToolBar.GetToolBarCtrl().SetExtendedStyle(TBSTYLE_WRAPABLE);
m_comToolBar.GetToolBarCtrl().SetRows(9,TRUE,&rect);
m_comToolBar.SetHeight(60);
解决方案 »
- MFC多视图应用中的视图客户区的图片上画文字,切换界面时文字不见了
- 如何GDI+技术 来过滤掉图片的背景色?
- LPTSTR 参数的问题
- dll包含dll的问题
- Windows API线程的问题!!求助!!
- 怎样在对话框中插入IE控件,来显示网页
- 如何给DHTML对象Sink Event,IE的事件是如何处理?
- 急,急 急, 高手快请进,为什莫没人回答我的问题呢?有200分
- 如何用 HANDLE 或 HINSTANCE 得到 HWND
- new操作符被MFC……
- 框架中有两个View,为什么在我调整窗口大小的时候,这两个View会闪烁不止?
- 我想在一副图上的几个位置显示一个闪烁的报警,应该怎样做?
具体是create一个Rebar,建立两个toolbar
然后insert两个band到Rebar控件里
每个band包含一个toolbar注意:toolbar有两个style必须要的
CCS_NORESIZE and CCS_NOPARENTALIGN具体看看msdn
或者你可以用以下这个函数
void CMainFrame::DockControlBarLeftOf(CControlBar *Bar, CControlBar *LeftOf)
{
CRect rect;
DWORD dw;
UINT n;
//计算WindowRect的精确大小
RecalcLayout();
LeftOf ->GetWindowRect(&rect);
rect.OffsetRect(1,0);
dw = LeftOf ->GetBarStyle();
n = 0;
n = (dw & CBRS_ALIGN_TOP) ? AFX_IDW_DOCKBAR_TOP : n;
n = (dw & CBRS_ALIGN_BOTTOM && n == 0) ? AFX_IDW_DOCKBAR_BOTTOM : n;
n = (dw & CBRS_ALIGN_LEFT && n == 0) ? AFX_IDW_DOCKBAR_LEFT : n;
n = (dw & CBRS_ALIGN_RIGHT && n == 0) ? AFX_IDW_DOCKBAR_RIGHT : n;DockControlBar(Bar, n, &rect);
}
两个不能并列排列,而是在同一行上。。
需要加什么参数啊
return -1;
if (!m_hotToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_hotToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
//
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_TOOLBAR1))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
// 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_hotToolBar.ModifyStyle(0, TBSTYLE_FLAT);
m_wndToolBar.ModifyStyle(0, TBSTYLE_FLAT);
// Set up hot bar image lists.
CImageList imageList,image2;
CBitmap bitmap,bt; // Create and set the normal toolbar image list.
bitmap.LoadBitmap(IDB_TOOLBAR_COLD);
imageList.Create(36, 48, ILC_COLORDDB|ILC_MASK, 13, 1);
imageList.Add(&bitmap, RGB(255,0,255));
m_hotToolBar.SendMessage(TB_SETIMAGELIST, 0, (LPARAM)imageList.m_hImageList);
// m_wndToolBar.SendMessage(TB_SETIMAGELIST, 0, (LPARAM)imageList.m_hImageList);
imageList.Detach();
bitmap.Detach(); // Create and set the hot toolbar image list.
bitmap.LoadBitmap(IDB_TOOLBAR_HOT);
imageList.Create(36, 48, ILC_COLORDDB|ILC_MASK, 13, 1);
imageList.Add(&bitmap, RGB(255,0,255));
m_hotToolBar.SendMessage(TB_SETHOTIMAGELIST, 0, (LPARAM)imageList.m_hImageList);
// m_wndToolBar.SendMessage(TB_SETHOTIMAGELIST, 0, (LPARAM)imageList.m_hImageList);
imageList.Detach();
bitmap.Detach();
//
// Create and set the normal toolbar image list.
bt.LoadBitmap(IDB_t1);
image2.Create(36, 24, ILC_COLORDDB|ILC_MASK, 13, 1);
image2.Add(&bt, RGB(255,0,255));
m_wndToolBar.SendMessage(TB_SETIMAGELIST, 0, (LPARAM)image2.m_hImageList);
image2.Detach();
bt.Detach(); // Create and set the hot toolbar image list.
bt.LoadBitmap(IDB_t2);
image2.Create(36, 24, ILC_COLORDDB|ILC_MASK, 13, 1);
image2.Add(&bt, RGB(255,0,255));
m_wndToolBar.SendMessage(TB_SETHOTIMAGELIST, 0, (LPARAM)image2.m_hImageList);
image2.Detach();
bt.Detach();
//
m_hotToolBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_hotToolBar);
DockControlBar(&m_wndToolBar); // CG: The following line was added by the Splash Screen component.
CSplashWnd::ShowSplashScreen(this);
return 0;