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.

323 lines
5.6 KiB

  1. /*++
  2. Copyright (c) 1994-2001 Microsoft Corporation
  3. Module Name :
  4. fmessage.cpp
  5. Abstract:
  6. FTP Messages property page
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Sergei Antonov (sergeia)
  10. Project:
  11. Internet Services Manager
  12. Revision History:
  13. --*/
  14. //
  15. // Include Files
  16. //
  17. #include "stdafx.h"
  18. #include "common.h"
  19. #include "inetprop.h"
  20. #include "InetMgrApp.h"
  21. #include "shts.h"
  22. #include "ftpsht.h"
  23. #include "fmessage.h"
  24. #ifdef _DEBUG
  25. #undef THIS_FILE
  26. static char BASED_CODE THIS_FILE[] = __FILE__;
  27. #endif
  28. IMPLEMENT_DYNCREATE(CFtpMessagePage, CInetPropertyPage)
  29. CFtpMessagePage::CFtpMessagePage(
  30. IN CInetPropertySheet * pSheet
  31. )
  32. /*++
  33. Routine Description:
  34. Constructor for FTP message property page
  35. Arguments:
  36. CInetPropertySheet * pSheet : Associated property sheet
  37. Return Value:
  38. N/A
  39. --*/
  40. : CInetPropertyPage(CFtpMessagePage::IDD, pSheet)
  41. {
  42. #ifdef _DEBUG
  43. afxMemDF |= checkAlwaysMemDF;
  44. #endif // _DEBUG
  45. #if 0 // Keep class wizard happy
  46. //{{AFX_DATA_INIT(CFtpMessagePage)
  47. m_strExitMessage = _T("");
  48. m_strMaxConMsg = _T("");
  49. m_strWelcome = _T("");
  50. //}}AFX_DATA_INIT
  51. #endif // 0
  52. m_hInstRichEdit = LoadLibrary(_T("RichEd20.dll"));
  53. }
  54. CFtpMessagePage::~CFtpMessagePage()
  55. /*++
  56. Routine Description:
  57. Destructor
  58. Arguments:
  59. N/A
  60. Return Value:
  61. N/A
  62. --*/
  63. {
  64. if (m_hInstRichEdit != NULL)
  65. FreeLibrary(m_hInstRichEdit);
  66. }
  67. void
  68. CFtpMessagePage::DoDataExchange(
  69. IN CDataExchange * pDX
  70. )
  71. /*++
  72. Routine Description:
  73. Initialise/Store control data
  74. Arguments:
  75. CDataExchange * pDX - DDX/DDV control structure
  76. Return Value:
  77. None
  78. --*/
  79. {
  80. CInetPropertyPage::DoDataExchange(pDX);
  81. //{{AFX_DATA_MAP(CFtpMessagePage)
  82. DDX_Control(pDX, IDC_EDIT_EXIT, m_edit_Exit);
  83. DDX_Control(pDX, IDC_EDIT_MAX_CONNECTIONS, m_edit_MaxCon);
  84. DDX_Text(pDX, IDC_EDIT_EXIT, m_strExitMessage);
  85. DDX_Text(pDX, IDC_EDIT_MAX_CONNECTIONS, m_strMaxConMsg);
  86. DDX_Text(pDX, IDC_EDIT_WELCOME, m_strWelcome);
  87. DDX_Text(pDX, IDC_EDIT_BANNER, m_strBanner);
  88. //}}AFX_DATA_MAP
  89. }
  90. //
  91. // Message Map
  92. //
  93. BEGIN_MESSAGE_MAP(CFtpMessagePage, CInetPropertyPage)
  94. //{{AFX_MSG_MAP(CFtpMessagePage)
  95. //}}AFX_MSG_MAP
  96. ON_EN_CHANGE(IDC_EDIT_EXIT, OnItemChanged)
  97. ON_EN_CHANGE(IDC_EDIT_MAX_CONNECTIONS, OnItemChanged)
  98. ON_EN_CHANGE(IDC_EDIT_WELCOME, OnItemChanged)
  99. ON_EN_CHANGE(IDC_EDIT_BANNER, OnItemChanged)
  100. END_MESSAGE_MAP()
  101. //
  102. // Message Handlers
  103. //
  104. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  105. BOOL
  106. CFtpMessagePage::OnInitDialog()
  107. /*++
  108. Routine Description:
  109. WM_INITDIALOG handler. Initialize the dialog.
  110. Arguments:
  111. None.
  112. Return Value:
  113. TRUE if no focus is to be set automatically, FALSE if the focus
  114. is already set.
  115. --*/
  116. {
  117. CInetPropertyPage::OnInitDialog();
  118. CHARFORMAT cf;
  119. ZeroMemory(&cf, sizeof(cf));
  120. cf.cbSize = sizeof(cf);
  121. cf.dwMask = CFM_FACE;
  122. cf.bPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
  123. lstrcpyn((LPTSTR)cf.szFaceName, _T("Courier"), LF_FACESIZE);
  124. SendDlgItemMessage(IDC_EDIT_WELCOME, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
  125. SendDlgItemMessage(IDC_EDIT_BANNER, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
  126. DWORD event = (DWORD)SendDlgItemMessage(IDC_EDIT_WELCOME, EM_GETEVENTMASK, 0, 0);
  127. event |= ENM_CHANGE;
  128. SendDlgItemMessage(IDC_EDIT_WELCOME, EM_SETEVENTMASK, 0, (LPARAM)event);
  129. event = (DWORD)SendDlgItemMessage(IDC_EDIT_BANNER, EM_GETEVENTMASK, 0, 0);
  130. event |= ENM_CHANGE;
  131. SendDlgItemMessage(IDC_EDIT_BANNER, EM_SETEVENTMASK, 0, (LPARAM)event);
  132. return TRUE;
  133. }
  134. /* virtual */
  135. HRESULT
  136. CFtpMessagePage::FetchLoadedValues()
  137. /*++
  138. Routine Description:
  139. Move configuration data from sheet to dialog controls
  140. Arguments:
  141. None
  142. Return Value:
  143. HRESULT
  144. --*/
  145. {
  146. CError err;
  147. BEGIN_META_INST_READ(CFtpSheet)
  148. //
  149. // Use m_ notation because the message cracker functions require it.
  150. //
  151. CStringListEx m_strlWelcome, m_strlBanner;
  152. FETCH_INST_DATA_FROM_SHEET(m_strExitMessage);
  153. FETCH_INST_DATA_FROM_SHEET(m_strMaxConMsg);
  154. FETCH_INST_DATA_FROM_SHEET(m_strlWelcome);
  155. FETCH_INST_DATA_FROM_SHEET(m_strlBanner);
  156. //
  157. // Incoming strings contain '\r' at the end of each string.
  158. // Append a '\n' for internal consumption
  159. //
  160. ConvertStringListToSepLine(m_strlWelcome, m_strWelcome, _T("\n"));
  161. ConvertStringListToSepLine(m_strlBanner, m_strBanner, _T("\n"));
  162. END_META_INST_READ(err)
  163. return err;
  164. }
  165. /* virtual */
  166. HRESULT
  167. CFtpMessagePage::SaveInfo()
  168. /*++
  169. Routine Description:
  170. Save the information on this property page
  171. Arguments:
  172. None
  173. Return Value:
  174. Error return code
  175. --*/
  176. {
  177. ASSERT(IsDirty());
  178. TRACEEOLID("Saving FTP message page now...");
  179. CError err;
  180. BeginWaitCursor();
  181. //
  182. // Use m_ notation because the message cracker macros require
  183. // it.
  184. //
  185. CStringListEx m_strlWelcome, m_strlBanner;
  186. ConvertSepLineToStringList(m_strWelcome, m_strlWelcome, _T("\n"));
  187. ConvertSepLineToStringList(m_strBanner, m_strlBanner, _T("\n"));
  188. BEGIN_META_INST_WRITE(CFtpSheet)
  189. STORE_INST_DATA_ON_SHEET(m_strExitMessage)
  190. STORE_INST_DATA_ON_SHEET(m_strMaxConMsg)
  191. STORE_INST_DATA_ON_SHEET(m_strlWelcome)
  192. STORE_INST_DATA_ON_SHEET(m_strlBanner)
  193. END_META_INST_WRITE(err)
  194. EndWaitCursor();
  195. return err;
  196. }
  197. void
  198. CFtpMessagePage::OnItemChanged()
  199. /*++
  200. Routine Description:
  201. Register a change in control value on this page. Mark the page as dirty.
  202. All change messages map to this function
  203. Arguments:
  204. None
  205. Return Value:
  206. None
  207. --*/
  208. {
  209. SetModified(TRUE);
  210. }