MainFrm.cpp
上传用户:qifu0001
上传日期:2007-01-02
资源大小:52k
文件大小:6k
源码类别:

TreeView控件

开发平台:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "TPS_Demo.h"
  5. #include "MainFrm.h"
  6. #include "TreePropertySheet.h"
  7. #include "GeneralPrefsDlg.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CMainFrame
  15. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  16. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  17. //{{AFX_MSG_MAP(CMainFrame)
  18. ON_WM_CREATE()
  19. ON_COMMAND(ID_VIEW_SPECIALCAPTION, OnViewSpecialCaption)
  20. ON_UPDATE_COMMAND_UI(ID_VIEW_SPECIALCAPTION, OnUpdateViewSpecialCaption)
  21. ON_COMMAND(ID_VIEW_NETSCAPESHEET, OnViewNetscapeSheet)
  22. ON_COMMAND(ID_VIEW_SIMPLESHEET, OnViewSimpleSheet)
  23. ON_COMMAND(ID_VIEW_USERSHEET, OnViewUsersSheet)
  24. //}}AFX_MSG_MAP
  25. END_MESSAGE_MAP()
  26. static UINT indicators[] =
  27. {
  28. ID_SEPARATOR,           // status line indicator
  29. ID_INDICATOR_CAPS,
  30. ID_INDICATOR_NUM,
  31. ID_INDICATOR_SCRL,
  32. };
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CMainFrame construction/destruction
  35. CMainFrame::CMainFrame()
  36. {
  37. // TODO: add member initialization code here
  38. m_bSpecialCaption=FALSE;
  39. }
  40. CMainFrame::~CMainFrame()
  41. {
  42. }
  43. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  44. {
  45. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  46. return -1;
  47. if (!m_wndToolBar.Create(this) ||
  48. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  49. {
  50. TRACE0("Failed to create toolbarn");
  51. return -1;      // fail to create
  52. }
  53. if (!m_wndStatusBar.Create(this) ||
  54. !m_wndStatusBar.SetIndicators(indicators,
  55.   sizeof(indicators)/sizeof(UINT)))
  56. {
  57. TRACE0("Failed to create status barn");
  58. return -1;      // fail to create
  59. }
  60. // TODO: Remove this if you don't want tool tips or a resizeable toolbar
  61. m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  62. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  63. // TODO: Delete these three lines if you don't want the toolbar to
  64. //  be dockable
  65. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  66. EnableDocking(CBRS_ALIGN_ANY);
  67. DockControlBar(&m_wndToolBar);
  68. return 0;
  69. }
  70. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  71. {
  72. // TODO: Modify the Window class or styles here by modifying
  73. //  the CREATESTRUCT cs
  74. return CFrameWnd::PreCreateWindow(cs);
  75. }
  76. /////////////////////////////////////////////////////////////////////////////
  77. // CMainFrame diagnostics
  78. #ifdef _DEBUG
  79. void CMainFrame::AssertValid() const
  80. {
  81. CFrameWnd::AssertValid();
  82. }
  83. void CMainFrame::Dump(CDumpContext& dc) const
  84. {
  85. CFrameWnd::Dump(dc);
  86. }
  87. #endif //_DEBUG
  88. /////////////////////////////////////////////////////////////////////////////
  89. // CMainFrame message handlers
  90. void CMainFrame::OnViewSpecialCaption() 
  91. {
  92. // TODO: Add your command handler code here
  93. m_bSpecialCaption=(m_bSpecialCaption)?FALSE:TRUE;
  94. }
  95. void CMainFrame::OnUpdateViewSpecialCaption(CCmdUI* pCmdUI) 
  96. {
  97. // TODO: Add your command update UI handler code here
  98. pCmdUI->SetCheck(m_bSpecialCaption);
  99. }
  100. #include "AnimalsPage.h"
  101. #include "CarsPage.h"
  102. #include "AboutPage.h"
  103. void CMainFrame::OnViewNetscapeSheet() 
  104. {
  105. // TODO: Add your command handler code here
  106. CTreePropertySheet tps;
  107. CGeneralPrefsDlg   cGeneralDlg;
  108. CAnimalsPage    cAnimalsPage;
  109. CCarsPage    cCarsPage;
  110. CAboutPage    cAboutPage;
  111. tps.AddPage(tps_item_branch,&cGeneralDlg,"Information about yourself");
  112. tps.AddPage(tps_item_node,&cAnimalsPage,"Information about animals");
  113. tps.AddPage(tps_item_endbranch,&cCarsPage,"Information about cars");
  114. tps.AddPage(tps_item_node,&cAboutPage,"About box ...");
  115. tps.SetLikeNetscape(m_bSpecialCaption);
  116. tps.DoModal();
  117. }
  118. void CMainFrame::OnViewSimpleSheet() 
  119. {
  120. // TODO: Add your command handler code here
  121. /* CTreePropertySheet tps;
  122. CGeneralPrefsDlg   cGeneralDlg;
  123. CAnimalsPage    cAnimalsPage;
  124. CCarsPage    cCarsPage;
  125. CAboutPage    cAboutPage;
  126. tps.AddPage(tps_item_branch,&cGeneralDlg,"Information about yourself");
  127. tps.AddPage(tps_item_node,&cAnimalsPage,"Information about animals");
  128. tps.AddPage(tps_item_endbranch,&cCarsPage,"Information about cars");
  129. tps.AddPage(tps_item_node,&cAboutPage,"About box ...");
  130. tps.SetSimple(m_bSpecialCaption);
  131. tps.DoModal();*/
  132. CTreePropertySheet *tps=new CTreePropertySheet;
  133. CGeneralPrefsDlg   *cGeneralDlg=new CGeneralPrefsDlg;
  134. CAnimalsPage    *cAnimalsPage=new CAnimalsPage;
  135. CCarsPage    *cCarsPage=new CCarsPage;
  136. CAboutPage    *cAboutPage=new CAboutPage;
  137. tps->AddPage(tps_item_branch,cGeneralDlg,"Information about yourself");
  138. tps->AddPage(tps_item_node,cAnimalsPage,"Information about animals");
  139. tps->AddPage(tps_item_endbranch,cCarsPage,"Information about cars");
  140. tps->AddPage(tps_item_node,cAboutPage,"About box ...");
  141. tps->SetSimple(m_bSpecialCaption);
  142. tps->Create();
  143. }
  144. void CMainFrame::OnViewUsersSheet() 
  145. {
  146. // TODO: Add your command handler code here
  147. CTreePropertySheet tps;
  148. CGeneralPrefsDlg   cGeneralDlg;
  149. CAnimalsPage    cAnimalsPage;
  150. CCarsPage    cCarsPage;
  151. CAboutPage    cAboutPage;
  152. tps.AddPage(tps_item_branch,&cGeneralDlg,"Information about yourself");
  153. tps.AddPage(tps_item_node,&cAnimalsPage,"Information about animals");
  154. tps.AddPage(tps_item_endbranch,&cCarsPage,"Information about cars");
  155. tps.AddPage(tps_item_node,&cAboutPage,"About box ...");
  156. CStatic *info=new CStatic();
  157. info->Create("<User defined caption>",WS_CHILD,CRect(0,0,200,16),GetDesktopWindow());
  158. CFont *tempF=tps.GetFont("MS Sans Serif",18);
  159. info->SetFont(tempF);
  160. tps.m_clrCaptionLeft =RGB(0,0,255);
  161. tps.m_clrCaptionRight =RGB(192,192,192);
  162. tps.m_clrCaptionTextLeft=RGB(255,255,255);
  163. tps.m_clrCaptionTextRight=RGB(0,0,0);
  164. tps.m_nCaptionBorder =tps_capborder_none;
  165. tps.m_bSpecialCaption =m_bSpecialCaption;
  166. tps.InsertExtraControl(tps_above,3,info,0,0,216,16,tps_horz_right|tps_vert_center,TRUE);
  167. tps.SetExtraRowSpace(tps_above,0,8,0);
  168. tps.DoModal();
  169. }