MainFrm.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:4k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. // This file is a part of the XTREME TOOLKIT PRO MFC class library.
  4. // (c)1998-2008 Codejock Software, All Rights Reserved.
  5. //
  6. // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
  7. // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
  8. // CONSENT OF CODEJOCK SOFTWARE.
  9. //
  10. // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
  11. // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
  12. // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
  13. // SINGLE COMPUTER.
  14. //
  15. // CONTACT INFORMATION:
  16. // support@codejock.com
  17. // http://www.codejock.com
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. #include "stdafx.h"
  21. #include "TabbedView.h"
  22. #include "MainFrm.h"
  23. #ifdef _DEBUG
  24. #define new DEBUG_NEW
  25. #undef THIS_FILE
  26. static char THIS_FILE[] = __FILE__;
  27. #endif
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CMainFrame
  30. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  31. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  32. //{{AFX_MSG_MAP(CMainFrame)
  33. // NOTE - the ClassWizard will add and remove mapping macros here.
  34. //    DO NOT EDIT what you see in these blocks of generated code !
  35. ON_WM_CREATE()
  36. ON_XTP_CREATECONTROL()
  37. ON_COMMAND(XTP_ID_CUSTOMIZE, OnCustomize)
  38. //}}AFX_MSG_MAP
  39. END_MESSAGE_MAP()
  40. static UINT indicators[] =
  41. {
  42. ID_SEPARATOR,           // status line indicator
  43. ID_INDICATOR_CAPS,
  44. ID_INDICATOR_NUM,
  45. ID_INDICATOR_SCRL,
  46. };
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CMainFrame construction/destruction
  49. CMainFrame::CMainFrame()
  50. {
  51. XTPImageManager()->m_bAutoResample = TRUE;
  52. }
  53. CMainFrame::~CMainFrame()
  54. {
  55. }
  56. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  57. {
  58. if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  59. return -1;
  60. if (!m_wndStatusBar.Create(this) ||
  61. !m_wndStatusBar.SetIndicators(indicators,
  62. sizeof(indicators)/sizeof(UINT)))
  63. {
  64. TRACE0("Failed to create status barn");
  65. return -1;      // fail to create
  66. }
  67. if (!InitCommandBars())
  68. return -1;
  69. CXTPPaintManager::SetTheme(xtpThemeOffice2003);
  70. CXTPCommandBars* pCommandBars = GetCommandBars();
  71. pCommandBars->SetMenu(_T("Menu Bar"), IDR_MAINFRAME);
  72. CXTPToolBar* pStandardBar = (CXTPToolBar*)pCommandBars->Add(_T("Standard"), xtpBarTop);
  73. if (!pStandardBar ||
  74. !pStandardBar->LoadToolBar(IDR_MAINFRAME))
  75. {
  76. TRACE0("Failed to create toolbarn");
  77. return -1;
  78. }
  79. // Load the previous state for command bars.
  80. LoadCommandBars(_T("CommandBars"));
  81. return 0;
  82. }
  83. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  84. {
  85. if( !CMDIFrameWnd::PreCreateWindow(cs) )
  86. return FALSE;
  87. cs.lpszClass = _T("XTPMainFrame");
  88. CXTPDrawHelpers::RegisterWndClass(AfxGetInstanceHandle(), cs.lpszClass, 
  89. CS_DBLCLKS, AfxGetApp()->LoadIcon(IDR_MAINFRAME));
  90. return TRUE;
  91. }
  92. /////////////////////////////////////////////////////////////////////////////
  93. // CMainFrame diagnostics
  94. #ifdef _DEBUG
  95. void CMainFrame::AssertValid() const
  96. {
  97. CMDIFrameWnd::AssertValid();
  98. }
  99. void CMainFrame::Dump(CDumpContext& dc) const
  100. {
  101. CMDIFrameWnd::Dump(dc);
  102. }
  103. #endif //_DEBUG
  104. /////////////////////////////////////////////////////////////////////////////
  105. // CMainFrame message handlers
  106. int CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl)
  107. {
  108. CXTPMenuBar* pMenuBar = DYNAMIC_DOWNCAST(CXTPMenuBar, lpCreateControl->pCommandBar);
  109. if (pMenuBar)
  110. {
  111. if (lpCreateControl->strCaption == _T("&Edit"))
  112. {
  113. ASSERT(lpCreateControl->pMenu);
  114. CMenu* pPopupMenu = lpCreateControl->pMenu->GetSubMenu(lpCreateControl->nIndex);
  115. CXTPControlPopup* pControlPopup = CXTPControlPopup::CreateControlPopup(xtpControlPopup);
  116. lpCreateControl->nID = ID_POPUP_EDIT;
  117. pControlPopup->SetCommandBar(pPopupMenu);
  118. lpCreateControl->pControl = pControlPopup;
  119. return TRUE;
  120. }
  121. }
  122. return FALSE;
  123. }
  124. void CMainFrame::OnCustomize()
  125. {
  126. CXTPCustomizeSheet cs(GetCommandBars());
  127. CXTPCustomizeOptionsPage pageOptions(&cs);
  128. cs.AddPage(&pageOptions);
  129. CXTPCustomizeCommandsPage* pCommands = cs.GetCommandsPage();
  130. pCommands->AddCategories(IDR_TABBEDTYPE);
  131. pCommands->InsertAllCommandsCategory();
  132. pCommands->InsertBuiltInMenus(IDR_TABBEDTYPE);
  133. pCommands->InsertNewMenuCategory();
  134. cs.DoModal();
  135. }