rt

解决方案 »

  1.   

    CToolBar * pToolBar = (CToolBar * ) AfxGetMainWnd ( )
    —> GetDescendantWindow(AFX_IDW_TOOLBAR)
      

  2.   

    同意  feiniaoliang(飞鸟良)   同时祝 feiniaoliang(飞鸟良)升级到星了
     另外注释一下!  
      CWnd * AfxGetMainWnd()
    返回值为主窗口句丙,失败为NULL
    CWnd* GetDescendantWindow(int nID,bOnlyPen=FALSE)const;
    返回子窗口句柄失败返回NULL,
    nID 子窗口标识  bOnlyPen说明临时窗口句柄是否能返回
    CToolBar * pToolBar = (CToolBar * ) AfxGetMainWnd ( )
    —> GetDescendantWindow(AFX_IDW_TOOLBAR)
      

  3.   

    试了一下,可以了。
    这里还有一点不清楚,CToolBar和CToolBarCtrl有什么区别?
      

  4.   

    MSDN上写得很清楚呀!!CToolBarCtrl usually results in a smaller executable, and you may prefer to use CToolBarCtrl if you do not intend to integrate the toolbar into the MFC architecture. If you plan to use CToolBarCtrl and integrate the toolbar into the MFC architecture, you must take additional care to communicate toolbar control manipulations to MFC. This communication is not difficult; however, it is additional work that is unneeded when you use CToolBar. 
      

  5.   

    那GetDescendantWindow(AFX_IDW_TOOLBAR)中的nID怎么知道使用这个AFX_IDW_TOOLBAR呢?具体参考在哪里找呀?
      

  6.   

    我想这样:在视图中点击鼠标便在工具栏最后加上一个按钮,这个按钮的图片是从一个DLL中导出的。现在可以看到工具栏上已经加上了一个按钮,但是是空白的。这是怎么回事呀?
      

  7.   

    缺省时, 工作框创建状态条和工具条时将它们作为主框窗口的子窗口,状态条
    有一个AFX_IDW_STATUS_BAR标识符,工具条有一个AFX_IDW_TOOLBAR标识符,
      

  8.   

    哦,原来是这样!谢谢feiniaoliang(飞鸟良) 。那第二个问题呢?我想这样:在视图中点击鼠标便在工具栏最后加上一个按钮,这个按钮的图片是从一个DLL中导出的。现在可以看到工具栏上已经加上了一个按钮,但是是空白的。这是怎么回事呀?
      

  9.   

    看看你的这个图片资源是否load成功!
      

  10.   

    谢谢 feiniaoliang(飞鸟良) 。
    我采用静态链接方式加载DLL的,所以在EXE中没有load图片资源的语句;只是在预编译头文件中包含lib的同时包含了DLL中的那个资源头文件。DLL中的那个资源头文件是我新建的,它包含了我在DLL中新建的一个Bitmap。
      

  11.   

    DLL中的那个资源头文件出现在了我的EXE工程中FileView的External Dependencies下面,这个可对呀?是不是代表Load成功了呢?