我想创建一个自己的TOOLBAR(可以在上面定义自己的功能按键),在程序启动后与系统的TOOLBAR分开显示.......

解决方案 »

  1.   

    选择Insert->Resource命令,然后在Insert Resource对话框中选中Toolbar。按了OK按钮后,在Toolbar资源类下就会出现一个ID为IDR_TOOLBAR1的新资源。
    剩下的步骤其实跟系统生成的那个ToolBar步骤一样。
    CToolBar m_myToolBar;
    if (!m_myToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
       | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) 
    ||!m_myToolBar.LoadToolBar(IDR_TOOLBAR1)
    {
    TRACE0("Failed to create toolbar\n");
    return -1;      // fail to create
    }
    m_myoolBar.EnableDocking(CBRS_ALIGN_ANY);
    EnableDocking(CBRS_ALIGN_ANY);
    DockControlBar(&m_wndToolBar);
      

  2.   

    我新建了一个class MYTOOLBAR : public CToolBarCtrl
    下面的函数不有被调用:
    int MTOOLBAR::OnCreate(LPCREATESTRUCT lpCreateStruct) 
    {
    AfxMessageBox("");
    if (CToolBarCtrl::OnCreate(lpCreateStruct) == -1)
    return -1;
    // TODO: Add your specialized creation code here

    return 0;
    }
    请说手指点!
      

  3.   

    你要有一个MYTOOLBAR变量m_toolbar,m_toolbar.Create才可以。
      

  4.   

    你说的“系统的TOOLBAR”就是向导生成的吧,模仿它写就是了,改一下变量名。
      

  5.   

    同2楼。.copy下改下名字  就有一个新的了
    然后设置Toolbar上的ID
    classwizard上加函数
      

  6.   

    谢谢各位大侠.....自己的TOOLBAR已经定义成功了.怎么才能使TOOLBAR自动停靠在窗口的边框处啊???
    我用下面的语句实现不了,
    m_myToolBar.EnableDocking(CBRS_ALIGN_RIGHT);
    EnableDocking(CBRS_ALIGN_RIGHT);
    DockControlBar(&m_myToolBar);准备接分!!!!
      

  7.   

    你创建得时候只只指定了,在上面阿,看看msdn上面关于createex得函数,
    BOOL CreateEx(CWnd* pParentWnd, DWORD dwCtrlStyle = TBSTYLE_FLAT, DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP, CRect rcBorders = CRect(0, 0, 0, 0), UINT nID = AFX_IDW_TOOLBAR);Return ValueNonzero if successful; otherwise 0.ParameterspParentWndPointer to the window that is the toolbar’s parent.dwCtrlStyleAdditional styles for the creation of the embedded CToolBarCtrl object. By default, this value is set to TBSTYLE_FLAT. For a complete list of toolbar styles, see dwStyle.dwStyleThe toolbar style. See Toolbar Control and Button Styles in the Platform SDK for a list of appropriate styles.rcBordersA CRect object that defines the widths of the toolbar window borders. These borders are set to 0,0,0,0 by default, thereby resulting in a toolbar window with no borders.nIDThe toolbar’s child-window ID.
      

  8.   

    谢过各位......接分!请问可不可以把CTOOLBAR设置成ResourceView下DIALG的控件栏风格(比如:以二列多行形式显示工具,另外不主动停靠在窗口某边而是悬浮在窗口中一个指定位置!)问题解决后,另开贴追加高分绝不行骗!