24小时热门版块排行榜    

查看: 154  |  回复: 0
当前主题已经存档。

zsglly

木虫 (著名写手)

[交流] 如何做出类似vc的workshop

我无意中在网上找到几个class,无须dll库就能轻松做出vc的workshop。不敢独享,特地把我的经验介绍出来,以供大家参考。

  

方法如下:

1.  将scbarg.h,scbarg.cpp,sizecbar.h,sizecbar.cpp,mybar.h,mybar.cpp文件copy到你的工程目录下,打开vc,将这几个文件添加进工程。

2.  打开stdafx.h文件,在其中加入:#include "sizecbar.h",#include "scbarg.h"。

3.  为CmainFrame类添加成员变量:CMyBar        m_wndMyBar。

4.  重载CMainFrame:estroyWindow(),在其中加入

       CString sProfile(_T("BarState");

       m_wndMyBar.SaveState(sProfile);

SaveBarState(sProfile);

5.  修改CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)如下:

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)

{

       if (CFrameWnd::OnCreate(lpCreateStruct) == -1)

              return -1;

        

       if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP

              | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||

              !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))

       {

              TRACE0("Failed to create toolbar\n";

              return -1;      // fail to create

       }

  

       if (!m_wndStatusBar.Create(this) ||

              !m_wndStatusBar.SetIndicators(indicators,

                sizeof(indicators)/sizeof(UINT)))

       {

              TRACE0("Failed to create status bar\n";

              return -1;      // fail to create

       }

       if (!m_wndMyBar.Create(_T("My Bar", this, 123))

   {

        TRACE0("Failed to create mybar\n";

        return -1;      // fail to create

       }

       // TODO: Delete these three lines if you don't want the toolbar to

       //  be dockable

       m_wndMyBar.SetBarStyle(m_wndMyBar.GetBarStyle() |

        CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

       m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);

       m_wndMyBar.EnableDocking(CBRS_ALIGN_ANY);  

       EnableDocking(CBRS_ALIGN_ANY);

       DockControlBar(&m_wndToolBar);

       DockControlBar(&m_wndMyBar, AFX_IDW_DOCKBAR_LEFT);

       CString sProfile(_T("BarState");

    if (VerifyBarState(sProfile))

    {

        m_wndMyBar.LoadState(sProfile);

        LoadBarState(sProfile);

    }

       return 0;

}

注:黑体部分为所加内容。

6.  在“查看”菜单下添加菜单项mybar,设其id为:ID_VIEW_MYBAR.

7.  为其添加CMainFrame::OnViewMybar(),CMainFrame::OnUpdateViewMybar(CCmdUI* pCmdUI)函数,内容为:

void CMainFrame::OnViewMybar()  

{

       // TODO: Add your command handler code here

       BOOL bShow = m_wndMyBar.IsVisible();

       ShowControlBar(&m_wndMyBar, !bShow, FALSE);

}

void CMainFrame::OnUpdateViewMybar(CCmdUI* pCmdUI)  

{

       // TODO: Add your command update UI handler code here

       pCmdUI->Enable();

       pCmdUI->SetCheck(m_wndMyBar.IsVisible());

}

编译运行即可,如果你想改变workshop中的cedit成员变量(如本例workshop中的树),只需改变mybar中的代码即可。

[ Last edited by 幻影无痕 on 2006-11-17 at 08:29 ]
回复此楼

» 猜你喜欢

做人要厚道啊!厚道啊!
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 zsglly 的主题更新
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 264求调剂 +4 巴拉巴拉根556 2026-02-28 4/200 2026-03-02 10:48 by yuchj
[考研] 0856材料与化工,270求调剂 +7 YXCT 2026-03-01 8/400 2026-03-02 10:37 by YXCT
[考研] 化工270求调剂 +6 什么名字qwq 2026-03-02 6/300 2026-03-02 10:21 by 黑!在干嘛
[考研] 调剂 +3 13853210211 2026-03-02 4/200 2026-03-02 10:16 by 13853210211
[考研] 材料类求调剂 +11 wana_kiko 2026-02-28 14/700 2026-03-02 08:46 by 聪明的大松鼠
[考研] 085600 英一数二272求调剂 5+3 vida_a 2026-03-01 7/350 2026-03-02 07:51 by ms629
[考研] 哈工大计算机刘劼团队招生 +3 hit_aiot 2026-03-01 5/250 2026-03-02 07:48 by 得鹿梦鱼111
[考研] 292求调剂 +6 yhk_819 2026-02-28 6/300 2026-03-01 23:23 by 向上的胖东
[考研] 江苏省农科院招调剂1名 +3 Qwertyuop 2026-03-01 3/150 2026-03-01 23:18 by aaadim
[考研] 265分求调剂不调专业和学校有行学上就 +6 礼堂丁真258 2026-02-28 8/400 2026-03-01 22:50 by jian_
[考研] 0856调剂 +5 刘梦微 2026-02-28 5/250 2026-03-01 22:30 by wang_dand
[考研] 0856求调剂285 +10 吕仔龙 2026-02-28 10/500 2026-03-01 21:37 by 公瑾逍遥
[考研] 298求调剂 +6 axyz3 2026-02-28 6/300 2026-03-01 19:00 by 18137688336
[考研] 328求调剂 +3 aaadim 2026-03-01 5/250 2026-03-01 17:29 by njzyff
[考研] 285求调剂 +8 满头大汗的学生 2026-02-28 8/400 2026-03-01 16:47 by caszguilin
[考研] 311求调剂 +6 亭亭亭01 2026-03-01 6/300 2026-03-01 15:41 by 324616
[考研] 302材料工程求调剂 +4 Doleres 2026-03-01 5/250 2026-03-01 11:52 by liqiongjy
[考研] 307求调剂 +4 73372112 2026-02-28 6/300 2026-03-01 00:04 by ll247
[考研] 304求调剂 +3 52hz~~ 2026-02-28 5/250 2026-03-01 00:00 by 52hz~~
[高分子] 求环氧树脂研发1名 +3 孙xc 2026-02-25 11/550 2026-02-28 16:57 by ichall
信息提示
请填处理意见