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

对话框与窗口

开发平台:

Visual C++

  1. // DynamicPopupsView.cpp : implementation of the CDynamicPopupsView 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 "DynamicPopups.h"
  22. #include "DynamicPopupsDoc.h"
  23. #include "DynamicPopupsView.h"
  24. #ifdef _DEBUG
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CDynamicPopupsView
  31. IMPLEMENT_DYNCREATE(CDynamicPopupsView, CFormView)
  32. BEGIN_MESSAGE_MAP(CDynamicPopupsView, CFormView)
  33. //{{AFX_MSG_MAP(CDynamicPopupsView)
  34. ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
  35. ON_BN_CLICKED(IDC_BUTTON_REMOVE, OnButtonRemove)
  36. ON_COMMAND(ID_BUTTON_ADD, OnButtonAdd)
  37. ON_COMMAND(ID_BUTTON_REMOVE, OnButtonRemove)
  38. ON_COMMAND(ID_BUTTON_POPUP, OnEmptyCommand)
  39. ON_COMMAND(ID_COMBO_UNDO, OnEmptyCommand)
  40. ON_COMMAND_RANGE(FIRST_UNDO_COMMAND, LAST_UNDO_COMMAND, OnUndoClick)
  41. ON_XTP_EXECUTE(ID_COMBO_ADD, OnComboAdd)
  42. ON_UPDATE_COMMAND_UI(ID_COMBO_ADD, OnEmptyUpdateCommand)
  43. //}}AFX_MSG_MAP
  44. // Standard printing commands
  45. ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
  46. ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
  47. ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
  48. END_MESSAGE_MAP()
  49. /////////////////////////////////////////////////////////////////////////////
  50. // CDynamicPopupsView construction/destruction
  51. CDynamicPopupsView::CDynamicPopupsView()
  52. : CFormView(CDynamicPopupsView::IDD)
  53. {
  54. //{{AFX_DATA_INIT(CDynamicPopupsView)
  55. m_strText = _T("");
  56. //}}AFX_DATA_INIT
  57. // TODO: add construction code here
  58. }
  59. CDynamicPopupsView::~CDynamicPopupsView()
  60. {
  61. }
  62. void CDynamicPopupsView::DoDataExchange(CDataExchange* pDX)
  63. {
  64. CFormView::DoDataExchange(pDX);
  65. //{{AFX_DATA_MAP(CDynamicPopupsView)
  66. DDX_Control(pDX, IDC_LIST, m_wndList);
  67. DDX_Text(pDX, IDC_EDIT, m_strText);
  68. //}}AFX_DATA_MAP
  69. }
  70. BOOL CDynamicPopupsView::PreCreateWindow(CREATESTRUCT& cs)
  71. {
  72. // TODO: Modify the Window class or styles here by modifying
  73. //  the CREATESTRUCT cs
  74. return CFormView::PreCreateWindow(cs);
  75. }
  76. void CDynamicPopupsView::OnInitialUpdate()
  77. {
  78. CFormView::OnInitialUpdate();
  79. ResizeParentToFit();
  80. m_wndList.AddString(_T("Undo Edit"));
  81. m_wndList.AddString(_T("Undo Resize"));
  82. }
  83. /////////////////////////////////////////////////////////////////////////////
  84. // CDynamicPopupsView printing
  85. BOOL CDynamicPopupsView::OnPreparePrinting(CPrintInfo* pInfo)
  86. {
  87. // default preparation
  88. return DoPreparePrinting(pInfo);
  89. }
  90. void CDynamicPopupsView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  91. {
  92. // TODO: add extra initialization before printing
  93. }
  94. void CDynamicPopupsView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  95. {
  96. // TODO: add cleanup after printing
  97. }
  98. void CDynamicPopupsView::OnPrint(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  99. {
  100. // TODO: add customized printing code here
  101. }
  102. /////////////////////////////////////////////////////////////////////////////
  103. // CDynamicPopupsView diagnostics
  104. #ifdef _DEBUG
  105. void CDynamicPopupsView::AssertValid() const
  106. {
  107. CFormView::AssertValid();
  108. }
  109. void CDynamicPopupsView::Dump(CDumpContext& dc) const
  110. {
  111. CFormView::Dump(dc);
  112. }
  113. CDynamicPopupsDoc* CDynamicPopupsView::GetDocument() // non-debug version is inline
  114. {
  115. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDynamicPopupsDoc)));
  116. return (CDynamicPopupsDoc*)m_pDocument;
  117. }
  118. #endif //_DEBUG
  119. /////////////////////////////////////////////////////////////////////////////
  120. // CDynamicPopupsView message handlers
  121. void CDynamicPopupsView::OnEmptyCommand()
  122. {
  123. }
  124. void CDynamicPopupsView::OnEmptyUpdateCommand(CCmdUI* pCmdUI)
  125. {
  126. pCmdUI->Enable();
  127. }
  128. void CDynamicPopupsView::OnButtonAdd()
  129. {
  130. UpdateData();
  131. if (m_strText.GetLength() > 0)
  132. {
  133. m_wndList.AddString(m_strText);
  134. }
  135. }
  136. void CDynamicPopupsView::OnButtonRemove()
  137. {
  138. int nIndex = m_wndList.GetCurSel();
  139. if (nIndex != -1)
  140. {
  141. m_wndList.DeleteString(nIndex);
  142. }
  143. }
  144. void CDynamicPopupsView::OnUndoClick(UINT nID)
  145. {
  146. int nIndex = nID - FIRST_UNDO_COMMAND;
  147. if (nIndex >= 0 && nIndex < m_wndList.GetCount())
  148. {
  149. CString strTitle;
  150. m_wndList.GetText(nIndex, strTitle);
  151. AfxMessageBox(strTitle);
  152. }
  153. }
  154. void CDynamicPopupsView::OnComboAdd(NMHDR* pNMHDR, LRESULT* pResult)
  155. {
  156. NMXTPCONTROL* tagNMCONTROL = (NMXTPCONTROL*)pNMHDR;
  157. CXTPControlComboBox* pCombo = (CXTPControlComboBox*)tagNMCONTROL->pControl;
  158. ASSERT(pCombo);
  159. ASSERT(pCombo->GetType() == xtpControlComboBox);
  160. CString strText;
  161. pCombo->GetEditCtrl()->GetWindowText(strText);
  162. if (strText.GetLength() > 0)
  163. {
  164. m_wndList.AddString(strText);
  165. pCombo->AddString(strText);
  166. }
  167. *pResult = 1;
  168. }