MDI窗体中,如果让不同的子窗口有不同的工具栏啊。。。

nightfallrove 2004-05-06 02:40:01
有很多不同的子窗口,但工具栏是停靠在MainFrame上的,,,
我想让不同的子窗口打开时就会有不同的工具栏,该怎么做?
可以是子框架中创建工具栏吗?
...全文
36 3 点赞 打赏 收藏 举报
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
nightfallrove 2004-05-08
好,
回去试试。。。
  • 打赏
  • 举报
回复
yycpp1 2004-05-07
How To Add a Toolbar in an MDI Child Window
Last reviewed: July 10, 1997
Article ID: Q155141
4.00 4.10 4.20 WINDOWS NT kbprg
The information in this article applies to:

The Microsoft Foundation Classes (MFC), included with: Microsoft Visual C++, 32-bit Edition, versions 4.0, 4.1, 4.2


SUMMARY
By default, an AppWizard-generated MDI application has a toolbar in its main application window (CMDIFrameWnd-derived class). This toolbar is shared by all the MDI child windows (CMDIChildWnd-derived class) in the application. In some cases, it would be useful to have a toolbar appear in each MDI child window. This is demonstrated in the following sample code.

Because CMDIChildWnd is a CFrameWnd-derived class, the toolbar in an MDI child window may be dockable. This can be easily achieved by calling such functions as EnableDocking() and DockControlBar().



Sample Code
Steps to create a toolbar in an MDI child window:


Create a CMDIChildWnd-derived class using ClassWizard if one is missing. Remember to use this derived class in the CMultiDocTemplate statement in the CWinApp::InitInstance() function.

Add a member variable of type CToolBar to the CMDIChildWnd-derived class.
class CChildFrame : public CMDIChildWnd { ...

CToolBar m_wndToolBar;
}



Override the OnCreate() function in your CMDIChildWnd-derived class using ClassWizard.

Add the following code to the OnCreate() function of your CMDIChildWnd- derived class:

int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
return -1;

// Create a toolbar window. IDR_CHILDFRAME is the resource name
// of the toolbar to be loaded.
if (!m_wndToolBar.Create(this) ||
!m_wndToolBar.LoadToolBar(IDR_CHILDFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}

// 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);

// 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);

return 0;
}


REFERENCES
For information on using ClassWizard, please refer to VC++ Books Online.
  • 打赏
  • 举报
回复
ygzdev 2004-05-06
先都创建,然后根据需要bar1.ShowWindow(TRUE);bar2.ShowWindow(FALSE);.....最后RecalcLayout();
  • 打赏
  • 举报
回复
相关推荐
发帖
界面
加入

1.5w+

社区成员

VC/MFC 界面
申请成为版主
帖子事件
创建了帖子
2004-05-06 02:40
社区公告
暂无公告