怎么在对话框上增加工具条???我的程序怎么不管用??

brat365 2002-11-08 04:29:19
BOOL CToolsDlg::OnInitDialog()
{
CToolBar m_wndToolBar;
m_wndToolBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_TOOLTIPS |CBRS_FLYBY | CBRS_BORDER_BOTTOM);
m_wndToolBar.LoadToolBar(IDR_TOOLBAR1);

}

为什么加不上啊??
是CDialog程序!!!!
...全文
69 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
llm308 2002-11-08
  • 打赏
  • 举报
回复
RepositionBars()是客户区重新计算
AFX_IDW_CONTROLBAR_FIRST 代表的数字为 0
AFX_IDW_CONTROLBAR_LAST 代表数字为 0xffff
你可以试试
RepositionBars(0,0xffff,NULL)也可以的
另外,在对话框中创建工具栏时应该用CreateEx()
用户 昵称 2002-11-08
  • 打赏
  • 举报
回复
创建工具条的代码
m_pImageList = new CImageList;
SetupImages(m_pImageList);

TBBUTTON tb;

m_ToolBar = new CToolBarCtrl;
m_ToolBar->Create(WS_CHILD|WS_VISIBLE|WS_BORDER|TBSTYLE_FLAT,
CRect(0,0,0,0), this, 0);

m_ToolBar->SetImageList(m_pImageList);
tb.iBitmap = 0;
tb.iString = NULL;
tb.fsState = TBSTATE_ENABLED;
tb.fsStyle = TBSTYLE_BUTTON;
tb.idCommand = ID_HELP_ABOUT;

m_ToolBar->AddButtons(1, &tb);
tb.iBitmap = 1;
tb.idCommand = ID_BOLD;
m_ToolBar->AddButtons(1, &tb);
tb.iBitmap = 2;
tb.idCommand = ID_DRAWING;
m_ToolBar->AddButtons(1, &tb);

TBBUTTON tb1;
tb1.fsStyle = TBSTYLE_SEP;
m_ToolBar->AddButtons(1, &tb1);

tb.iBitmap = 3;
tb.idCommand = ID_STRIKEOUT;
tb.iString = NULL;
m_ToolBar->AddButtons(1, &tb);
qing_li73 2002-11-08
  • 打赏
  • 举报
回复
See the useful sampel below, FYI :

http://www.codeproject.com/docking/display_dialog_tooltips.asp
qing_li73 2002-11-08
  • 打赏
  • 举报
回复
Remarks

Called to reposition and resize control bars in the client area of a window. The nIDFirst and nIDLast parameters define a range of control-bar IDs to be repositioned in the client area. The nIDLeftOver parameter specifies the ID of the child window (normally the view) which is repositioned and resized to fill the rest of the client area not filled by control bars.

nbgyf 2002-11-08
  • 打赏
  • 举报
回复
1.这里RepositionBars()是什么意思??
--------Called to reposition and resize control bars in the client area of a window.

brat365 2002-11-08
  • 打赏
  • 举报
回复
解决了!!谢谢
但还是有点不明白啊!·!

m_wndToolBar.CreateEx( this,TBSTYLE_FLAT , WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS,CRect(0,0,0,0));
m_wndToolBar.LoadToolBar(IDR_TOOLBAR1);
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST, 0);

这里RepositionBars()是什么意思??
AFX_IDW_CONTROLBAR_FIRST有是什么?在msdn里都没找到啊!

谢谢
brat365 2002-11-08
  • 打赏
  • 举报
回复
还是不成啊!!!!
首先在:OnInitDialog中加上:
if (!m_wndToolBar.Create( this ) ||
!m_wndToolBar.LoadToolBar(IDR_TOOLBAR1) )
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}

m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY );

怎么还是不显示!!!!!!!!!!!!!????????????????????????!!!!!!!!!!!!!!!!!!
司马青衫依旧 2002-11-08
  • 打赏
  • 举报
回复
http://www.vckbase.com/vckbase/vckbase11
对话框目录中的《在Dialog中使用Menu和Toolbar》
zhuwenzheng 2002-11-08
  • 打赏
  • 举报
回复
http://www.codeguru.com/dialog/toolbars.shtml
brat365 2002-11-08
  • 打赏
  • 举报
回复
还是不成!
anothervip 2002-11-08
  • 打赏
  • 举报
回复
把CToolBar m_wndToolBar放在对话框的类定义中,试试。

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧