MainFrm.cpp
上传用户:qifu0001
上传日期:2007-01-02
资源大小:52k
文件大小:6k
- // MainFrm.cpp : implementation of the CMainFrame class
- //
- #include "stdafx.h"
- #include "TPS_Demo.h"
- #include "MainFrm.h"
- #include "TreePropertySheet.h"
- #include "GeneralPrefsDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
- IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
- BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- ON_WM_CREATE()
- ON_COMMAND(ID_VIEW_SPECIALCAPTION, OnViewSpecialCaption)
- ON_UPDATE_COMMAND_UI(ID_VIEW_SPECIALCAPTION, OnUpdateViewSpecialCaption)
- ON_COMMAND(ID_VIEW_NETSCAPESHEET, OnViewNetscapeSheet)
- ON_COMMAND(ID_VIEW_SIMPLESHEET, OnViewSimpleSheet)
- ON_COMMAND(ID_VIEW_USERSHEET, OnViewUsersSheet)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- static UINT indicators[] =
- {
- ID_SEPARATOR, // status line indicator
- ID_INDICATOR_CAPS,
- ID_INDICATOR_NUM,
- ID_INDICATOR_SCRL,
- };
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame construction/destruction
- CMainFrame::CMainFrame()
- {
- // TODO: add member initialization code here
-
- m_bSpecialCaption=FALSE;
- }
- CMainFrame::~CMainFrame()
- {
- }
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- if (!m_wndToolBar.Create(this) ||
- !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
- {
- TRACE0("Failed to create toolbarn");
- return -1; // fail to create
- }
- if (!m_wndStatusBar.Create(this) ||
- !m_wndStatusBar.SetIndicators(indicators,
- sizeof(indicators)/sizeof(UINT)))
- {
- TRACE0("Failed to create status barn");
- return -1; // fail to create
- }
- // TODO: Remove this if you don't want tool tips or a resizeable toolbar
- m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
- CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
- // TODO: Delete these three lines if you don't want the toolbar to
- // be dockable
- m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
- EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(&m_wndToolBar);
- return 0;
- }
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CFrameWnd::PreCreateWindow(cs);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame diagnostics
- #ifdef _DEBUG
- void CMainFrame::AssertValid() const
- {
- CFrameWnd::AssertValid();
- }
- void CMainFrame::Dump(CDumpContext& dc) const
- {
- CFrameWnd::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame message handlers
- void CMainFrame::OnViewSpecialCaption()
- {
- // TODO: Add your command handler code here
-
- m_bSpecialCaption=(m_bSpecialCaption)?FALSE:TRUE;
- }
- void CMainFrame::OnUpdateViewSpecialCaption(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
-
- pCmdUI->SetCheck(m_bSpecialCaption);
- }
- #include "AnimalsPage.h"
- #include "CarsPage.h"
- #include "AboutPage.h"
- void CMainFrame::OnViewNetscapeSheet()
- {
- // TODO: Add your command handler code here
- CTreePropertySheet tps;
- CGeneralPrefsDlg cGeneralDlg;
- CAnimalsPage cAnimalsPage;
- CCarsPage cCarsPage;
- CAboutPage cAboutPage;
- tps.AddPage(tps_item_branch,&cGeneralDlg,"Information about yourself");
- tps.AddPage(tps_item_node,&cAnimalsPage,"Information about animals");
- tps.AddPage(tps_item_endbranch,&cCarsPage,"Information about cars");
- tps.AddPage(tps_item_node,&cAboutPage,"About box ...");
- tps.SetLikeNetscape(m_bSpecialCaption);
- tps.DoModal();
- }
- void CMainFrame::OnViewSimpleSheet()
- {
- // TODO: Add your command handler code here
- /* CTreePropertySheet tps;
- CGeneralPrefsDlg cGeneralDlg;
- CAnimalsPage cAnimalsPage;
- CCarsPage cCarsPage;
- CAboutPage cAboutPage;
- tps.AddPage(tps_item_branch,&cGeneralDlg,"Information about yourself");
- tps.AddPage(tps_item_node,&cAnimalsPage,"Information about animals");
- tps.AddPage(tps_item_endbranch,&cCarsPage,"Information about cars");
- tps.AddPage(tps_item_node,&cAboutPage,"About box ...");
- tps.SetSimple(m_bSpecialCaption);
- tps.DoModal();*/
- CTreePropertySheet *tps=new CTreePropertySheet;
- CGeneralPrefsDlg *cGeneralDlg=new CGeneralPrefsDlg;
- CAnimalsPage *cAnimalsPage=new CAnimalsPage;
- CCarsPage *cCarsPage=new CCarsPage;
- CAboutPage *cAboutPage=new CAboutPage;
- tps->AddPage(tps_item_branch,cGeneralDlg,"Information about yourself");
- tps->AddPage(tps_item_node,cAnimalsPage,"Information about animals");
- tps->AddPage(tps_item_endbranch,cCarsPage,"Information about cars");
- tps->AddPage(tps_item_node,cAboutPage,"About box ...");
- tps->SetSimple(m_bSpecialCaption);
- tps->Create();
- }
- void CMainFrame::OnViewUsersSheet()
- {
- // TODO: Add your command handler code here
- CTreePropertySheet tps;
- CGeneralPrefsDlg cGeneralDlg;
- CAnimalsPage cAnimalsPage;
- CCarsPage cCarsPage;
- CAboutPage cAboutPage;
- tps.AddPage(tps_item_branch,&cGeneralDlg,"Information about yourself");
- tps.AddPage(tps_item_node,&cAnimalsPage,"Information about animals");
- tps.AddPage(tps_item_endbranch,&cCarsPage,"Information about cars");
- tps.AddPage(tps_item_node,&cAboutPage,"About box ...");
- CStatic *info=new CStatic();
- info->Create("<User defined caption>",WS_CHILD,CRect(0,0,200,16),GetDesktopWindow());
- CFont *tempF=tps.GetFont("MS Sans Serif",18);
- info->SetFont(tempF);
- tps.m_clrCaptionLeft =RGB(0,0,255);
- tps.m_clrCaptionRight =RGB(192,192,192);
- tps.m_clrCaptionTextLeft=RGB(255,255,255);
- tps.m_clrCaptionTextRight=RGB(0,0,0);
- tps.m_nCaptionBorder =tps_capborder_none;
- tps.m_bSpecialCaption =m_bSpecialCaption;
- tps.InsertExtraControl(tps_above,3,info,0,0,216,16,tps_horz_right|tps_vert_center,TRUE);
- tps.SetExtraRowSpace(tps_above,0,8,0);
- tps.DoModal();
- }