Leaked source code of windows server 2003
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
6.5 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. ON_EN_CHANGE(IDC_EDIT_EXIT, OnItemChanged)
  95. ON_EN_CHANGE(IDC_EDIT_MAX_CONNECTIONS, OnItemChanged)
  96. ON_EN_CHANGE(IDC_EDIT_WELCOME, OnItemChanged)
  97. ON_EN_CHANGE(IDC_EDIT_BANNER, OnItemChanged)
  98. END_MESSAGE_MAP()
  99. BOOL
  100. CFtpMessagePage::OnInitDialog()
  101. {
  102. CInetPropertyPage::OnInitDialog();
  103. CHARFORMAT2 cf;
  104. ZeroMemory(&cf, sizeof(cf));
  105. cf.cbSize = sizeof(cf);
  106. cf.dwMask = CFM_FACE | CFM_WEIGHT;
  107. cf.wWeight = FW_REGULAR;
  108. lstrcpyn((LPTSTR)cf.szFaceName, _T("Courier New"), LF_FACESIZE);
  109. DWORD event;
  110. if (GetSheet()->QueryMajorVersion() >= 6)
  111. {
  112. SendDlgItemMessage(IDC_EDIT_BANNER, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
  113. event = (DWORD)SendDlgItemMessage(IDC_EDIT_BANNER, EM_GETEVENTMASK, 0, 0);
  114. event |= ENM_CHANGE;
  115. SendDlgItemMessage(IDC_EDIT_BANNER, EM_SETEVENTMASK, 0, (LPARAM)event);
  116. }
  117. else
  118. {
  119. CRect rcText, rcBanner, rcWelcome;
  120. CWnd * pbt, * pwt, * pbe, * pwe;
  121. pbt = GetDlgItem(IDC_STATIC_BANNER);
  122. pbe = GetDlgItem(IDC_EDIT_BANNER);
  123. pwt = GetDlgItem(IDC_STATIC_WELCOME);
  124. pwe = GetDlgItem(IDC_EDIT_WELCOME);
  125. pbt->GetWindowRect(&rcText);
  126. ScreenToClient(&rcText);
  127. pbe->GetWindowRect(&rcBanner);
  128. ScreenToClient(&rcBanner);
  129. pbt->EnableWindow(FALSE);
  130. pbt->ShowWindow(SW_HIDE);
  131. pbe->EnableWindow(FALSE);
  132. pbe->ShowWindow(SW_HIDE);
  133. pwt->SetWindowPos(NULL, rcText.left, rcText.top, 0, 0,
  134. SWP_NOSIZE | SWP_NOZORDER);
  135. pwe->GetWindowRect(&rcWelcome);
  136. ScreenToClient(&rcWelcome);
  137. pwe->SetWindowPos(NULL, rcBanner.left, rcBanner.top,
  138. rcWelcome.Width(), rcWelcome.bottom - rcBanner.top,
  139. SWP_NOZORDER);
  140. }
  141. SendDlgItemMessage(IDC_EDIT_WELCOME, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
  142. event = (DWORD)SendDlgItemMessage(IDC_EDIT_WELCOME, EM_GETEVENTMASK, 0, 0);
  143. event |= ENM_CHANGE;
  144. SendDlgItemMessage(IDC_EDIT_WELCOME, EM_SETEVENTMASK, 0, (LPARAM)event);
  145. return TRUE;
  146. }
  147. /* virtual */
  148. HRESULT
  149. CFtpMessagePage::FetchLoadedValues()
  150. /*++
  151. Routine Description:
  152. Move configuration data from sheet to dialog controls
  153. Arguments:
  154. None
  155. Return Value:
  156. HRESULT
  157. --*/
  158. {
  159. CError err;
  160. BEGIN_META_INST_READ(CFtpSheet)
  161. //
  162. // Use m_ notation because the message cracker functions require it.
  163. //
  164. CStringListEx m_strlWelcome, m_strlBanner;
  165. FETCH_INST_DATA_FROM_SHEET(m_strExitMessage);
  166. FETCH_INST_DATA_FROM_SHEET(m_strMaxConMsg);
  167. FETCH_INST_DATA_FROM_SHEET(m_strlWelcome);
  168. FETCH_INST_DATA_FROM_SHEET(m_strlBanner);
  169. //
  170. // Incoming strings contain '\r' at the end of each string.
  171. // Append a '\n' for internal consumption
  172. //
  173. ConvertStringListToSepLine(m_strlWelcome, m_strWelcome, _T("\n"));
  174. ConvertStringListToSepLine(m_strlBanner, m_strBanner, _T("\n"));
  175. END_META_INST_READ(err)
  176. return err;
  177. }
  178. /* virtual */
  179. HRESULT
  180. CFtpMessagePage::SaveInfo()
  181. /*++
  182. Routine Description:
  183. Save the information on this property page
  184. Arguments:
  185. None
  186. Return Value:
  187. Error return code
  188. --*/
  189. {
  190. ASSERT(IsDirty());
  191. TRACEEOLID("Saving FTP message page now...");
  192. CError err;
  193. BeginWaitCursor();
  194. //
  195. // Use m_ notation because the message cracker macros require
  196. // it.
  197. //
  198. CStringListEx m_strlWelcome, m_strlBanner;
  199. ConvertSepLineToStringList(m_strWelcome, m_strlWelcome, _T("\n"));
  200. ConvertSepLineToStringList(m_strBanner, m_strlBanner, _T("\n"));
  201. BEGIN_META_INST_WRITE(CFtpSheet)
  202. STORE_INST_DATA_ON_SHEET(m_strExitMessage)
  203. STORE_INST_DATA_ON_SHEET(m_strMaxConMsg)
  204. STORE_INST_DATA_ON_SHEET(m_strlWelcome)
  205. STORE_INST_DATA_ON_SHEET(m_strlBanner)
  206. END_META_INST_WRITE(err)
  207. EndWaitCursor();
  208. return err;
  209. }
  210. void
  211. CFtpMessagePage::OnItemChanged()
  212. /*++
  213. Routine Description:
  214. Register a change in control value on this page. Mark the page as dirty.
  215. All change messages map to this function
  216. Arguments:
  217. None
  218. Return Value:
  219. None
  220. --*/
  221. {
  222. SetModified(TRUE);
  223. }