尝试在 Mainframe 类 VS 6.0 中创建我自己的工具栏

发布于 2024-07-16 11:55:33 字数 2158 浏览 2 评论 0原文

我在大型机内创建自己的工具栏时遇到问题。 我有一些按钮位图,我想将其用于我自己的工具栏,但问题是工具栏显示在我的 SDI 应用程序的视图内。 这是错误显示的工具栏的图片。

http://www.flickr.com/photos/14402427@N02/3409050475/< /a>

这是 Mainframe 类的 OnCreate 函数内的代码:我也有一个

// CToolBarCtrl m_wndToolBar; declared inside the MainFrame.h class.


      if(m_wndToolBar.Create(WS_CHILD |  TBSTYLE_FLAT | WS_VISIBLE | CBRS_TOP
        | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC
            ,CRect(0,0,250,50),this,0))
    {
        TRACE0("Failed to create toolbar\n");
        return -1;      // fail to create
    }

        TBBUTTON       tbbutton[3] = {0};
      CSize        button_size(90,90);      
      CSize        bitmap_size(80,80);     

      //m_wndToolBar.AddStrings("String 1\0String 2\0String 3\0");

      tbbutton[0].iBitmap                  = 0;      
      tbbutton[0].idCommand            = ID_CONNECT;
    tbbutton[0].fsState                  = TBSTATE_ENABLED;      
      tbbutton[0].fsStyle                  = TBSTYLE_BUTTON;
      tbbutton[0].dwData                  = 0;     
      tbbutton[0].iString                  = 0;

      tbbutton[1].iBitmap                  = 1;      
      tbbutton[1].idCommand            = ID_DISCONNECT;
    tbbutton[1].fsState                  = TBSTATE_ENABLED;       
      tbbutton[1].fsStyle                  = TBSTYLE_BUTTON;
    tbbutton[1].dwData                  = 0;     
      tbbutton[1].iString                  = 1;

      tbbutton[2].iBitmap                  = 2;      
      tbbutton[2].idCommand              = ID_STOP;
    tbbutton[2].fsState                  = TBSTATE_ENABLED;      
      tbbutton[2].fsStyle                  = TBSTYLE_BUTTON   ;
    tbbutton[2].dwData                  = 0;     
      tbbutton[2].iString                  = 2;

m_wndToolBar.SetButtonSize(button_size);
m_wndToolBar.SetBitmapSize( bitmap_size);

m_wndToolBar.AddButtons(3,tbbutton);
m_wndToolBar.AddBitmap(1,IDB_BITMAP1);
m_wndToolBar.AddBitmap(1,IDB_BITMAP2);
m_wndToolBar.AddBitmap(1,IDB_BITMAP3);

return TRUE;

I am having issues with creating my own Toolbar inside the Mainframe. I have bitmaps of buttons which I want to use for my own Toolbar but the problem is that the Toolbar displays inside the View of my SDI application. Here is a pic of the incorrectly displayed Toolbar.

http://www.flickr.com/photos/14402427@N02/3409050475/

Here is the code inside the OnCreate function of the Mainframe class : I also have a

// CToolBarCtrl m_wndToolBar; declared inside the MainFrame.h class.


      if(m_wndToolBar.Create(WS_CHILD |  TBSTYLE_FLAT | WS_VISIBLE | CBRS_TOP
        | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC
            ,CRect(0,0,250,50),this,0))
    {
        TRACE0("Failed to create toolbar\n");
        return -1;      // fail to create
    }

        TBBUTTON       tbbutton[3] = {0};
      CSize        button_size(90,90);      
      CSize        bitmap_size(80,80);     

      //m_wndToolBar.AddStrings("String 1\0String 2\0String 3\0");

      tbbutton[0].iBitmap                  = 0;      
      tbbutton[0].idCommand            = ID_CONNECT;
    tbbutton[0].fsState                  = TBSTATE_ENABLED;      
      tbbutton[0].fsStyle                  = TBSTYLE_BUTTON;
      tbbutton[0].dwData                  = 0;     
      tbbutton[0].iString                  = 0;

      tbbutton[1].iBitmap                  = 1;      
      tbbutton[1].idCommand            = ID_DISCONNECT;
    tbbutton[1].fsState                  = TBSTATE_ENABLED;       
      tbbutton[1].fsStyle                  = TBSTYLE_BUTTON;
    tbbutton[1].dwData                  = 0;     
      tbbutton[1].iString                  = 1;

      tbbutton[2].iBitmap                  = 2;      
      tbbutton[2].idCommand              = ID_STOP;
    tbbutton[2].fsState                  = TBSTATE_ENABLED;      
      tbbutton[2].fsStyle                  = TBSTYLE_BUTTON   ;
    tbbutton[2].dwData                  = 0;     
      tbbutton[2].iString                  = 2;

m_wndToolBar.SetButtonSize(button_size);
m_wndToolBar.SetBitmapSize( bitmap_size);

m_wndToolBar.AddButtons(3,tbbutton);
m_wndToolBar.AddBitmap(1,IDB_BITMAP1);
m_wndToolBar.AddBitmap(1,IDB_BITMAP2);
m_wndToolBar.AddBitmap(1,IDB_BITMAP3);

return TRUE;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心凉怎暖 2024-07-23 11:55:33

return 之前添加对 DockControlBar(&m_wndToolBar) 的调用。

Add a call to DockControlBar(&m_wndToolBar) just before the return.

绝影如岚 2024-07-23 11:55:33

从您的图像来看,它似乎没有绘制或绘制不正确,您是否尝试先添加位图,然后添加按钮? 或者你可以在 m_wndToolbarBar 上调用 AutoSize 吗?

From your image it seems that it is not painted or not painted correctly, did you try adding bitmaps first and then adding buttons? or can you call AutoSize on the m_wndToolbarBar.?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文