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.

266 lines
7.5 KiB

  1. // ActionLogFilePage.cpp : implementation file
  2. //
  3. // 03/05/00 v-marfin bug 59643 : Make this the default starting page.
  4. // 03/28/00 v-marfin bug 61030 Change Browse for file dialog to fix default extension. Also
  5. // changed conversion of filesize and other minor bugs.
  6. #include "stdafx.h"
  7. #include "snapin.h"
  8. #include "ActionLogFilePage.h"
  9. #include "Action.h"
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CActionLogFilePage property page
  17. IMPLEMENT_DYNCREATE(CActionLogFilePage, CHMPropertyPage)
  18. CActionLogFilePage::CActionLogFilePage() : CHMPropertyPage(CActionLogFilePage::IDD)
  19. {
  20. //{{AFX_DATA_INIT(CActionLogFilePage)
  21. m_sFileName = _T("");
  22. m_sText = _T("");
  23. m_iTextType = -1;
  24. m_iSize = 0;
  25. //}}AFX_DATA_INIT
  26. m_sHelpTopic = _T("HMon21.chm::/dlogact.htm");
  27. }
  28. CActionLogFilePage::~CActionLogFilePage()
  29. {
  30. }
  31. void CActionLogFilePage::DoDataExchange(CDataExchange* pDX)
  32. {
  33. CHMPropertyPage::DoDataExchange(pDX);
  34. //{{AFX_DATA_MAP(CActionLogFilePage)
  35. DDX_Control(pDX, IDC_EDIT_TEXT, m_TextWnd);
  36. DDX_Control(pDX, IDC_COMBO_LOGSIZE_UNITS, m_SizeUnits);
  37. DDX_Text(pDX, IDC_EDIT_LOGFILENAME, m_sFileName);
  38. DDX_Text(pDX, IDC_EDIT_TEXT, m_sText);
  39. DDX_Radio(pDX, IDC_RADIO_TEXT_TYPE_ASCII, m_iTextType);
  40. DDX_Text(pDX, IDC_EDIT_LOGSIZE, m_iSize);
  41. //}}AFX_DATA_MAP
  42. }
  43. BEGIN_MESSAGE_MAP(CActionLogFilePage, CHMPropertyPage)
  44. //{{AFX_MSG_MAP(CActionLogFilePage)
  45. ON_BN_CLICKED(IDC_BUTTON_BROWSE_FILE, OnButtonBrowseFile)
  46. ON_EN_CHANGE(IDC_EDIT_LOGFILENAME, OnChangeEditLogfilename)
  47. ON_EN_CHANGE(IDC_EDIT_TEXT, OnChangeEditText)
  48. ON_BN_CLICKED(IDC_RADIO_TEXT_TYPE_ASCII, OnRadioTextTypeAscii)
  49. ON_BN_CLICKED(IDC_RADIO_TEXT_TYPE_UNICODE, OnRadioTextTypeUnicode)
  50. ON_BN_CLICKED(IDC_BUTTON_INSERTION, OnButtonInsertion)
  51. ON_EN_CHANGE(IDC_EDIT_LOGSIZE, OnChangeEditLogsize)
  52. ON_CBN_SELENDOK(IDC_COMBO_LOGSIZE_UNITS, OnSelendokComboLogsizeUnits)
  53. ON_WM_DESTROY()
  54. //}}AFX_MSG_MAP
  55. END_MESSAGE_MAP()
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CActionLogFilePage message handlers
  58. BOOL CActionLogFilePage::OnInitDialog()
  59. {
  60. // v-marfin : bug 59643 : This will be the default starting page for the property
  61. // sheet so call CnxPropertyPageCreate() to unmarshal the
  62. // connection for this thread. This function must be called
  63. // by the first page of the property sheet. It used to
  64. // be called by the "General" page and its call still remains
  65. // there as well in case the general page is loaded by a
  66. // different code path that does not also load this page.
  67. // The CnxPropertyPageCreate function has been safeguarded
  68. // to simply return if the required call has already been made.
  69. // CnxPropertyPageDestory() must be called from this page's
  70. // OnDestroy function.
  71. // unmarshal connmgr
  72. CnxPropertyPageCreate();
  73. CHMPropertyPage::OnInitDialog();
  74. if( ! m_InsertionMenu.Create(&m_TextWnd,GetObjectPtr(),false) )
  75. {
  76. GetDlgItem(IDC_BUTTON_INSERTION)->EnableWindow(FALSE);
  77. }
  78. CWbemClassObject* pConsumerObject = ((CAction*)GetObjectPtr())->GetConsumerClassObject();
  79. if( pConsumerObject )
  80. {
  81. pConsumerObject->GetProperty(_T("Filename"),m_sFileName);
  82. pConsumerObject->GetProperty(_T("Text"),m_sText);
  83. CString sSize;
  84. pConsumerObject->GetProperty(_T("MaximumFileSize"),sSize);
  85. m_iSize = (UINT)_ttol(sSize); // v-marfin 61030
  86. m_SizeUnits.SetCurSel(0);
  87. bool bIsUnicode = false;
  88. pConsumerObject->GetProperty(_T("IsUnicode"),bIsUnicode);
  89. m_iTextType = bIsUnicode == true ? 1 : 0;
  90. delete pConsumerObject;
  91. }
  92. SendDlgItemMessage(IDC_SPIN1,UDM_SETRANGE32,0,999999999L);
  93. SendDlgItemMessage(IDC_SPIN3,UDM_SETRANGE32,0,999999999L);
  94. UpdateData(FALSE);
  95. return TRUE; // return TRUE unless you set the focus to a control
  96. // EXCEPTION: OCX Property Pages should return FALSE
  97. }
  98. BOOL CActionLogFilePage::OnApply()
  99. {
  100. if( ! CHMPropertyPage::OnApply() )
  101. {
  102. return FALSE;
  103. }
  104. UpdateData();
  105. if( m_sFileName.IsEmpty() )
  106. {
  107. return FALSE;
  108. }
  109. // v-marfin 61030 : Store in proper units but leave UI unchanged.
  110. UINT nSize = m_iSize;
  111. switch( m_SizeUnits.GetCurSel() )
  112. {
  113. case 1: // kilobytes
  114. {
  115. // m_iSize *= 1024; // v-marfin 61030
  116. nSize *= 1024;
  117. }
  118. break;
  119. case 2: // megabytes
  120. {
  121. //m_iSize *= (1024*1024); // v-marfin 61030
  122. nSize *= (1024*1024);
  123. }
  124. break;
  125. }
  126. CWbemClassObject* pConsumerObject = ((CAction*)GetObjectPtr())->GetConsumerClassObject();
  127. if( pConsumerObject )
  128. {
  129. pConsumerObject->SetProperty(_T("Filename"),m_sFileName);
  130. pConsumerObject->SetProperty(_T("Text"),m_sText);
  131. CString sSize;
  132. sSize.Format(_T("%lu"),nSize); // v-marfin 61030
  133. pConsumerObject->SetProperty(_T("MaximumFileSize"),sSize);
  134. bool bIsUnicode = m_iTextType == 0 ? false : true;
  135. pConsumerObject->SetProperty(_T("IsUnicode"),bIsUnicode);
  136. pConsumerObject->SaveAllProperties();
  137. delete pConsumerObject;
  138. }
  139. SetModified(FALSE);
  140. return TRUE;
  141. }
  142. void CActionLogFilePage::OnButtonBrowseFile()
  143. {
  144. CString sFilter;
  145. CString sTitle;
  146. sFilter.LoadString(IDS_STRING_FILTER);
  147. sTitle.LoadString(IDS_STRING_BROWSE_FILE);
  148. // v-marfin 61030 Change Browse for file dialog
  149. // CFileDialog fdlg(TRUE,_T("*.*"),NULL,OFN_FILEMUSTEXIST|OFN_SHAREAWARE|OFN_HIDEREADONLY,sFilter);
  150. CFileDialog fdlg(TRUE, // Is FILEOPEN dialog?
  151. NULL, // default extension if no extension provided
  152. NULL, // initial filename
  153. OFN_SHAREAWARE|OFN_HIDEREADONLY, // flags
  154. sFilter); // filter
  155. fdlg.m_ofn.lpstrTitle = sTitle;
  156. if( fdlg.DoModal() == IDOK )
  157. {
  158. m_sFileName = fdlg.GetPathName();
  159. UpdateData(FALSE);
  160. }
  161. }
  162. void CActionLogFilePage::OnChangeEditLogfilename()
  163. {
  164. // TODO: If this is a RICHEDIT control, the control will not
  165. // send this notification unless you override the CHMPropertyPage::OnInitDialog()
  166. // function and call CRichEditCtrl().SetEventMask()
  167. // with the ENM_CHANGE flag ORed into the mask.
  168. SetModified();
  169. }
  170. void CActionLogFilePage::OnChangeEditText()
  171. {
  172. // TODO: If this is a RICHEDIT control, the control will not
  173. // send this notification unless you override the CHMPropertyPage::OnInitDialog()
  174. // function and call CRichEditCtrl().SetEventMask()
  175. // with the ENM_CHANGE flag ORed into the mask.
  176. SetModified();
  177. }
  178. void CActionLogFilePage::OnRadioTextTypeAscii()
  179. {
  180. SetModified();
  181. }
  182. void CActionLogFilePage::OnRadioTextTypeUnicode()
  183. {
  184. SetModified();
  185. }
  186. void CActionLogFilePage::OnButtonInsertion()
  187. {
  188. CPoint pt;
  189. GetCursorPos(&pt);
  190. m_InsertionMenu.DisplayMenu(pt);
  191. UpdateData();
  192. SetModified();
  193. }
  194. void CActionLogFilePage::OnChangeEditLogsize()
  195. {
  196. // TODO: If this is a RICHEDIT control, the control will not
  197. // send this notification unless you override the CHMPropertyPage::OnInitDialog()
  198. // function and call CRichEditCtrl().SetEventMask()
  199. // with the ENM_CHANGE flag ORed into the mask.
  200. // TODO: Add your control notification handler code here
  201. SetModified(); // v-marfin 61030
  202. }
  203. void CActionLogFilePage::OnSelendokComboLogsizeUnits()
  204. {
  205. // TODO: Add your control notification handler code here
  206. SetModified(); // v-marfin 61030
  207. }
  208. void CActionLogFilePage::OnDestroy()
  209. {
  210. CHMPropertyPage::OnDestroy();
  211. // v-marfin : bug 59643 : CnxPropertyPageDestory() must be called from this page's
  212. // OnDestroy function.
  213. CnxPropertyPageDestroy();
  214. }