Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

274 lines
7.3 KiB

  1. // ActionEmailPage.cpp : implementation file
  2. //
  3. // 03/05/00 v-marfin bug 59643 : Make this the default starting page.
  4. #include "stdafx.h"
  5. #include "snapin.h"
  6. #include "ActionEmailPage.h"
  7. #include "Action.h"
  8. #include "BccDialog.h"
  9. #include "CcDialog.h"
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CActionEmailPage property page
  17. IMPLEMENT_DYNCREATE(CActionEmailPage, CHMPropertyPage)
  18. CActionEmailPage::CActionEmailPage() : CHMPropertyPage(CActionEmailPage::IDD)
  19. {
  20. //{{AFX_DATA_INIT(CActionEmailPage)
  21. m_sMessage = _T("");
  22. m_sServer = _T("");
  23. m_sSubject = _T("");
  24. m_sTo = _T("");
  25. //}}AFX_DATA_INIT
  26. m_sHelpTopic = _T("HMon21.chm::/demact.htm");
  27. }
  28. CActionEmailPage::~CActionEmailPage()
  29. {
  30. }
  31. void CActionEmailPage::DoDataExchange(CDataExchange* pDX)
  32. {
  33. CHMPropertyPage::DoDataExchange(pDX);
  34. //{{AFX_DATA_MAP(CActionEmailPage)
  35. DDX_Control(pDX, IDC_EDIT_MESSAGE, m_MessageWnd);
  36. DDX_Text(pDX, IDC_EDIT_MESSAGE, m_sMessage);
  37. DDX_Text(pDX, IDC_EDIT_SERVER, m_sServer);
  38. DDX_Control(pDX, IDC_EDIT_SUBJECT, m_SubjectWnd);
  39. DDX_Text(pDX, IDC_EDIT_SUBJECT, m_sSubject);
  40. DDX_Text(pDX, IDC_EDIT_TO, m_sTo);
  41. //}}AFX_DATA_MAP
  42. }
  43. BEGIN_MESSAGE_MAP(CActionEmailPage, CHMPropertyPage)
  44. //{{AFX_MSG_MAP(CActionEmailPage)
  45. ON_EN_CHANGE(IDC_EDIT_BCC, OnChangeEditBcc)
  46. ON_EN_CHANGE(IDC_EDIT_CC, OnChangeEditCc)
  47. ON_EN_CHANGE(IDC_EDIT_MESSAGE, OnChangeEditMessage)
  48. ON_EN_CHANGE(IDC_EDIT_SERVER, OnChangeEditServer)
  49. ON_EN_CHANGE(IDC_EDIT_SUBJECT, OnChangeEditSubject)
  50. ON_EN_CHANGE(IDC_EDIT_TO, OnChangeEditTo)
  51. ON_BN_CLICKED(IDC_BUTTON_BCC, OnButtonBcc)
  52. ON_BN_CLICKED(IDC_BUTTON_CC, OnButtonCc)
  53. ON_BN_CLICKED(IDC_BUTTON_INSERTION, OnButtonInsertion)
  54. ON_BN_CLICKED(IDC_BUTTON_SUBJECT_INSERTION, OnButtonSubjectInsertion)
  55. ON_WM_DESTROY()
  56. //}}AFX_MSG_MAP
  57. END_MESSAGE_MAP()
  58. /////////////////////////////////////////////////////////////////////////////
  59. // CActionEmailPage message handlers
  60. BOOL CActionEmailPage::OnInitDialog()
  61. {
  62. // v-marfin : bug 59643 : This will be the default starting page for the property
  63. // sheet so call CnxPropertyPageCreate() to unmarshal the
  64. // connection for this thread. This function must be called
  65. // by the first page of the property sheet. It used to
  66. // be called by the "General" page and its call still remains
  67. // there as well in case the general page is loaded by a
  68. // different code path that does not also load this page.
  69. // The CnxPropertyPageCreate function has been safeguarded
  70. // to simply return if the required call has already been made.
  71. // CnxPropertyPageDestory() must be called from this page's
  72. // OnDestroy function.
  73. // unmarshal connmgr
  74. CnxPropertyPageCreate();
  75. CHMPropertyPage::OnInitDialog();
  76. if( ! m_InsertionMenu.Create(&m_MessageWnd,GetObjectPtr(),false) )
  77. {
  78. GetDlgItem(IDC_BUTTON_INSERTION)->EnableWindow(FALSE);
  79. }
  80. // v-marfin : 61671
  81. if( ! m_SubjectInsertionMenu.Create(&m_SubjectWnd,GetObjectPtr(),false) )
  82. {
  83. GetDlgItem(IDC_BUTTON_SUBJECT_INSERTION)->EnableWindow(FALSE);
  84. }
  85. CWbemClassObject* pConsumerObject = ((CAction*)GetObjectPtr())->GetConsumerClassObject();
  86. if( pConsumerObject )
  87. {
  88. pConsumerObject->GetProperty(_T("ToLine"),m_sTo);
  89. pConsumerObject->GetProperty(_T("CcLine"),m_sCc);
  90. pConsumerObject->GetProperty(_T("BccLine"),m_sBcc);
  91. pConsumerObject->GetProperty(_T("SMTPServer"),m_sServer);
  92. if( ! m_sServer.CompareNoCase(_T("NOOP")) )
  93. {
  94. m_sServer.Empty();
  95. }
  96. pConsumerObject->GetProperty(_T("Message"),m_sMessage);
  97. pConsumerObject->GetProperty(_T("Subject"),m_sSubject);
  98. delete pConsumerObject;
  99. }
  100. SendDlgItemMessage(IDC_SPIN1,UDM_SETRANGE32,0,9999);
  101. UpdateData(FALSE);
  102. return TRUE; // return TRUE unless you set the focus to a control
  103. // EXCEPTION: OCX Property Pages should return FALSE
  104. }
  105. BOOL CActionEmailPage::OnApply()
  106. {
  107. if( ! CHMPropertyPage::OnApply() )
  108. {
  109. return FALSE;
  110. }
  111. UpdateData();
  112. CWbemClassObject* pConsumerObject = ((CAction*)GetObjectPtr())->GetConsumerClassObject();
  113. if( pConsumerObject )
  114. {
  115. pConsumerObject->SetProperty(_T("ToLine"),m_sTo);
  116. pConsumerObject->SetProperty(_T("CcLine"),m_sCc);
  117. pConsumerObject->SetProperty(_T("BccLine"),m_sBcc);
  118. pConsumerObject->SetProperty(_T("SMTPServer"),m_sServer);
  119. pConsumerObject->SetProperty(_T("Message"),m_sMessage);
  120. pConsumerObject->SetProperty(_T("Subject"),m_sSubject);
  121. pConsumerObject->SaveAllProperties();
  122. delete pConsumerObject;
  123. }
  124. SetModified(FALSE);
  125. return TRUE;
  126. }
  127. void CActionEmailPage::OnChangeEditBcc()
  128. {
  129. // TODO: If this is a RICHEDIT control, the control will not
  130. // send this notification unless you override the CHMPropertyPage::OnInitDialog()
  131. // function and call CRichEditCtrl().SetEventMask()
  132. // with the ENM_CHANGE flag ORed into the mask.
  133. SetModified();
  134. }
  135. void CActionEmailPage::OnChangeEditCc()
  136. {
  137. // TODO: If this is a RICHEDIT control, the control will not
  138. // send this notification unless you override the CHMPropertyPage::OnInitDialog()
  139. // function and call CRichEditCtrl().SetEventMask()
  140. // with the ENM_CHANGE flag ORed into the mask.
  141. SetModified();
  142. }
  143. void CActionEmailPage::OnChangeEditMessage()
  144. {
  145. // TODO: If this is a RICHEDIT control, the control will not
  146. // send this notification unless you override the CHMPropertyPage::OnInitDialog()
  147. // function and call CRichEditCtrl().SetEventMask()
  148. // with the ENM_CHANGE flag ORed into the mask.
  149. SetModified();
  150. }
  151. void CActionEmailPage::OnChangeEditServer()
  152. {
  153. // TODO: If this is a RICHEDIT control, the control will not
  154. // send this notification unless you override the CHMPropertyPage::OnInitDialog()
  155. // function and call CRichEditCtrl().SetEventMask()
  156. // with the ENM_CHANGE flag ORed into the mask.
  157. SetModified();
  158. }
  159. void CActionEmailPage::OnChangeEditSubject()
  160. {
  161. // TODO: If this is a RICHEDIT control, the control will not
  162. // send this notification unless you override the CHMPropertyPage::OnInitDialog()
  163. // function and call CRichEditCtrl().SetEventMask()
  164. // with the ENM_CHANGE flag ORed into the mask.
  165. SetModified();
  166. }
  167. void CActionEmailPage::OnChangeEditTo()
  168. {
  169. // TODO: If this is a RICHEDIT control, the control will not
  170. // send this notification unless you override the CHMPropertyPage::OnInitDialog()
  171. // function and call CRichEditCtrl().SetEventMask()
  172. // with the ENM_CHANGE flag ORed into the mask.
  173. SetModified();
  174. }
  175. void CActionEmailPage::OnButtonBcc()
  176. {
  177. CBccDialog dlg;
  178. dlg.m_sBcc = m_sBcc;
  179. if( dlg.DoModal() == IDOK )
  180. {
  181. m_sBcc = dlg.m_sBcc;
  182. }
  183. }
  184. void CActionEmailPage::OnButtonCc()
  185. {
  186. CCcDialog dlg;
  187. dlg.m_sCc = m_sCc;
  188. if( dlg.DoModal() == IDOK )
  189. {
  190. m_sCc = dlg.m_sCc;
  191. }
  192. }
  193. void CActionEmailPage::OnButtonInsertion()
  194. {
  195. CPoint pt;
  196. GetCursorPos(&pt);
  197. m_InsertionMenu.DisplayMenu(pt);
  198. UpdateData();
  199. SetModified();
  200. }
  201. void CActionEmailPage::OnButtonSubjectInsertion()
  202. {
  203. CPoint pt;
  204. GetCursorPos(&pt);
  205. m_SubjectInsertionMenu.DisplayMenu(pt);
  206. UpdateData();
  207. SetModified();
  208. }
  209. void CActionEmailPage::OnDestroy()
  210. {
  211. CHMPropertyPage::OnDestroy();
  212. // v-marfin : bug 59643 : CnxPropertyPageDestory() must be called from this page's
  213. // OnDestroy function.
  214. CnxPropertyPageDestroy();
  215. }