| 查看: 144 | 回复: 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 ] |
» 猜你喜欢
存款400万可以在学校里躺平吗
已经有15人回复
拟解决的关键科学问题还要不要写
已经有6人回复
Materials Today Chemistry审稿周期
已经有6人回复
基金委咋了?2026年的指南还没有出来?
已经有10人回复
基金申报
已经有6人回复
推荐一本书
已经有13人回复
国自然申请面上模板最新2026版出了吗?
已经有17人回复
纳米粒子粒径的测量
已经有8人回复
疑惑?
已经有5人回复
计算机、0854电子信息(085401-058412)调剂
已经有5人回复












estroyWindow(),在其中加入
);
回复此楼