24小时热门版块排行榜    

查看: 155  |  回复: 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 的主题更新
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 材料292调剂 +8 橘颂思美人 2026-03-23 8/400 2026-03-24 16:33 by laoshidan
[考研] 300求调剂,材料科学英一数二 +5 leaflight 2026-03-24 5/250 2026-03-24 16:25 by laoshidan
[考研] 求调剂一志愿武汉理工大学材料工程(085601) +5 WW.' 2026-03-23 7/350 2026-03-24 14:50 by sprinining
[考研] 321求调剂 +4 Ymlll 2026-03-24 4/200 2026-03-24 14:44 by sprinining
[考研] 081700 调剂 267分 +9 迷人的哈哈 2026-03-23 9/450 2026-03-24 11:58 by 544594351
[考研] 环境学硕288求调剂 +8 皮皮皮123456 2026-03-22 8/400 2026-03-23 23:47 by 热情沙漠
[考研] 384求调剂 +3 子系博 2026-03-22 6/300 2026-03-23 21:45 by 子系博
[考研] 材料专硕英一数二306 +8 z1z2z3879 2026-03-18 8/400 2026-03-23 20:49 by baobaoye
[考研] 336求调剂 +4 收到VS 2026-03-20 4/200 2026-03-23 19:02 by macy2011
[考研] 298求调剂 +8 上岸6666@ 2026-03-20 8/400 2026-03-23 11:02 by laoshidan
[考研] 生物学调剂 +5 Surekei 2026-03-21 5/250 2026-03-22 14:39 by tcx007
[考研] 269专硕求调剂 +6 金恩贝 2026-03-21 6/300 2026-03-22 14:31 by ColorlessPI
[考研] 考研调剂 +3 呼呼?~+123456 2026-03-21 3/150 2026-03-21 20:04 by 无际的草原
[考研] 求调剂 +6 Mqqqqqq 2026-03-19 6/300 2026-03-21 08:04 by JourneyLucky
[考研] 324分 085600材料化工求调剂 +4 llllkkkhh 2026-03-18 4/200 2026-03-21 01:24 by JourneyLucky
[考研] 一志愿 西北大学 ,070300化学学硕,总分287,双非一本,求调剂。 +3 晨昏线与星海 2026-03-18 3/150 2026-03-21 00:46 by JourneyLucky
[考研] 296求调剂 +6 www_q 2026-03-18 10/500 2026-03-20 23:56 by JourneyLucky
[考研] 考研调剂求学校推荐 +3 伯乐29 2026-03-18 5/250 2026-03-20 22:59 by JourneyLucky
[考研] 295复试调剂 +8 简木ChuFront 2026-03-19 8/400 2026-03-20 20:44 by zhukairuo
[考研] 261求B区调剂,科研经历丰富 +3 牛奶很忙 2026-03-20 4/200 2026-03-20 19:34 by JourneyLucky
信息提示
请填处理意见