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

对话框与窗口

开发平台:

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 "ListBoxSample.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_DYNCREATE(CMainFrame, CFrameWnd)
  31. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  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_WM_CLOSE()
  37. //}}AFX_MSG_MAP
  38. ON_XTP_CREATECONTROL()
  39. ON_COMMAND(XTP_ID_CUSTOMIZE, OnCustomize)
  40. END_MESSAGE_MAP()
  41. static UINT indicators[] =
  42. {
  43. ID_SEPARATOR,           // status line indicator
  44. ID_INDICATOR_CAPS,
  45. ID_INDICATOR_NUM,
  46. ID_INDICATOR_SCRL,
  47. };
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CMainFrame construction/destruction
  50. CMainFrame::CMainFrame()
  51. {
  52. // TODO: add member initialization code here
  53. }
  54. CMainFrame::~CMainFrame()
  55. {
  56. }
  57. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  58. {
  59. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  60. return -1;
  61. if (!m_wndStatusBar.Create(this) ||
  62. !m_wndStatusBar.SetIndicators(indicators,
  63. sizeof(indicators)/sizeof(UINT)))
  64. {
  65. TRACE0("Failed to create status barn");
  66. return -1;      // fail to create
  67. }
  68. if (!InitCommandBars())
  69. return -1;
  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. CXTPPaintManager::SetTheme(xtpThemeOffice2003);
  80. LoadCommandBars(_T("CommandBars"));
  81. return 0;
  82. }
  83. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  84. {
  85. if( !CFrameWnd::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. CFrameWnd::AssertValid();
  98. }
  99. void CMainFrame::Dump(CDumpContext& dc) const
  100. {
  101. CFrameWnd::Dump(dc);
  102. }
  103. #endif //_DEBUG
  104. /////////////////////////////////////////////////////////////////////////////
  105. // CMainFrame message handlers
  106. int CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl)
  107. {
  108. if (lpCreateControl->bToolBar)
  109. {
  110. CXTPToolBar* pToolBar = DYNAMIC_DOWNCAST(CXTPToolBar, lpCreateControl->pCommandBar);
  111. if (!pToolBar)
  112. return FALSE;
  113. /*  if (lpCreateControl->nID == ID_EDIT_UNDO && pToolBar->GetBarID() == IDR_MAINFRAME)
  114. {
  115. //CXTPControlListBox* pComboFind = (CXTPControlListBox*)CXTPControlListBox::CreateObject();
  116. //lpCreateControl->pControl = pComboFind;
  117. //return TRUE;
  118. }*/
  119. if (lpCreateControl->nID == ID_EDIT_UNDO && pToolBar->GetBarID() == IDR_MAINFRAME)
  120. {
  121. CXTPControlPopup* pButtonUndo = CXTPControlPopup::CreateControlPopup(xtpControlSplitButtonPopup);
  122. CXTPPopupToolBar* pUndoBar = CXTPPopupToolBar::CreatePopupToolBar(GetCommandBars());
  123. pUndoBar->EnableCustomization(FALSE);
  124. pUndoBar->SetBorders(CRect(2, 2, 2, 2));
  125. pUndoBar->DisableShadow();
  126. CXTPControlListBox* pControlListBox = (CXTPControlListBox*)pUndoBar->GetControls()->Add(new CXTPControlListBox(), ID_EDIT_UNDO);
  127. pControlListBox->SetWidth(140);
  128. pControlListBox->SetLinesMinMax(1, 6);
  129. pControlListBox->SetMultiplSel(TRUE);
  130. CXTPControlStatic* pControlListBoxInfo = (CXTPControlStatic*)pUndoBar->GetControls()->Add(new CXTPControlStatic(), ID_EDIT_UNDO);
  131. pControlListBoxInfo->SetWidth(140);
  132. pButtonUndo->SetCommandBar(pUndoBar);
  133. pUndoBar->InternalRelease();
  134. lpCreateControl->pControl = pButtonUndo;
  135. return TRUE;
  136. }
  137. }
  138. return FALSE;
  139. }
  140. void CMainFrame::OnCustomize()
  141. {
  142. CXTPCustomizeSheet cs(GetCommandBars());
  143. CXTPCustomizeOptionsPage pageOptions(&cs);
  144. cs.AddPage(&pageOptions);
  145. CXTPCustomizeCommandsPage* pCommands = cs.GetCommandsPage();
  146. pCommands->AddCategories(IDR_MAINFRAME);
  147. pCommands->InsertAllCommandsCategory();
  148. pCommands->InsertBuiltInMenus(IDR_MAINFRAME);
  149. pCommands->InsertNewMenuCategory();
  150. cs.DoModal();
  151. }
  152. void CMainFrame::OnClose()
  153. {
  154. SaveCommandBars(_T("CommandBars"));
  155. CFrameWnd::OnClose();
  156. }