如何给CDiaLog 加上CReBar和CToolBar

gjp77 2002-07-23 08:35:43
如何给CDiaLog 加上CReBar和CToolBar
...全文
85 点赞 收藏 4
写回复
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
masterz 2002-07-24
what is your problem?
do you succeed now?
回复
gjp77 2002-07-24
现在我能把 ToolBar 加到 dialog上了但还不能加Rebar
不知道如何加?
回复
masterz 2002-07-24
1.add some member to in the CXXXDlg class
CToolBar m_wndToolBar;
CToolBar m_wndToolBar2;
CReBar m_ReBar;

2.Insert 2 toolbar resource to the project
ID_TOOLBAR1
ID_TOOLBAR2

3. add message handler to WM_CREATE message of CXXXDlg

int CPictrlDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;

// Create the Toolbar and attach the resource
if(!m_wndToolBar.Create(this) || !m_wndToolBar.LoadToolBar(IDR_TOOLBAR1))
{
TRACE0("Failed to Create Dialog Toolbar\n");
EndDialog(IDCANCEL);
}
if(!m_wndToolBar2.Create(this) || !m_wndToolBar2.LoadToolBar(IDR_TOOLBAR2))
{
TRACE0("Failed to Create Dialog Toolbar\n");
EndDialog(IDCANCEL);
}
m_ReBar.Create(this);
m_ReBar.AddBar(&m_wndToolBar);
m_ReBar.AddBar(&m_wndToolBar2);
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,
AFX_IDW_CONTROLBAR_LAST,0);

return 0;
}

4. add message handler to buttons in toolbar
open toolbar resource, click a small icon, press "Alt+Enter", change the resource ID, then use class wizard to add message handler to this ID.
回复
masterz 2002-07-24
http://www.codeguru.com/dialog/PlacingAToolbarOnADlg.shtml
回复
发动态
发帖子
VC/MFC
创建于2007-09-28

1.5w+

社区成员

VC/MFC相关问题讨论
申请成为版主
社区公告
暂无公告