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.

268 lines
6.9 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1996.
  5. //
  6. // File: once.cxx
  7. //
  8. // Contents: Task wizard once trigger property page implementation.
  9. //
  10. // Classes: CPasswordPage
  11. //
  12. // History: 4-28-1997 DavidMun Created
  13. //
  14. //---------------------------------------------------------------------------
  15. #include "..\pch\headers.hxx"
  16. #pragma hdrstop
  17. #include "myheaders.hxx"
  18. //
  19. // External functions
  20. //
  21. void
  22. GetDefaultDomainAndUserName(
  23. LPTSTR ptszDomainAndUserName,
  24. ULONG cchBuf);
  25. // header files say '256' - help files say 127
  26. // testing shows 127 is the real number
  27. #define REAL_PWLEN 127
  28. //+--------------------------------------------------------------------------
  29. //
  30. // Member: CPasswordPage::CPasswordPage
  31. //
  32. // Synopsis: ctor
  33. //
  34. // Arguments: [ptszFolderPath] - full path to tasks folder with dummy
  35. // filename appended
  36. // [phPSP] - filled with prop page handle
  37. //
  38. // History: 4-28-1997 DavidMun Created
  39. //
  40. //---------------------------------------------------------------------------
  41. CPasswordPage::CPasswordPage(
  42. CTaskWizard *pParent,
  43. LPTSTR ptszFolderPath,
  44. HPROPSHEETPAGE *phPSP):
  45. _pParent(pParent),
  46. CWizPage(MAKEINTRESOURCE(IDD_PASSWORD), ptszFolderPath)
  47. {
  48. TRACE_CONSTRUCTOR(CPasswordPage);
  49. *_tszUserName = TCHAR('\0');
  50. *_tszPassword = TCHAR('\0');
  51. *_tszConfirmPassword = TCHAR('\0');
  52. _CreatePage(IDS_TRIGGER_HDR1, IDS_PASSWORD_HDR2, phPSP);
  53. }
  54. //+--------------------------------------------------------------------------
  55. //
  56. // Member: CPasswordPage::~CPasswordPage
  57. //
  58. // Synopsis: dtor
  59. //
  60. // History: 4-28-1997 DavidMun Created
  61. //
  62. //---------------------------------------------------------------------------
  63. CPasswordPage::~CPasswordPage()
  64. {
  65. TRACE_DESTRUCTOR(CPasswordPage);
  66. ZeroCredentials();
  67. }
  68. //===========================================================================
  69. //
  70. // CPropPage overrides
  71. //
  72. //===========================================================================
  73. //+--------------------------------------------------------------------------
  74. //
  75. // Member: CPasswordPage::_OnCommand
  76. //
  77. // Synopsis: Update stored credential information and Next button state
  78. // in response to user input to the account or password edits.
  79. //
  80. // Arguments: [id] - resource id of control affected
  81. // [hwndCtl] - window handle of control affected
  82. // [codeNotify] - indicates what happened to control
  83. //
  84. // Returns: 0 (handled), 1 (not handled)
  85. //
  86. // History: 5-20-1997 DavidMun Created
  87. //
  88. //---------------------------------------------------------------------------
  89. LRESULT
  90. CPasswordPage::_OnCommand(
  91. INT id,
  92. HWND hwndCtl,
  93. UINT codeNotify)
  94. {
  95. LRESULT lr = 0;
  96. if (codeNotify == EN_UPDATE)
  97. {
  98. switch (id)
  99. {
  100. case password_name_edit:
  101. Edit_GetText(hwndCtl, _tszUserName, ARRAYLEN(_tszUserName));
  102. StripLeadTrailSpace(_tszUserName);
  103. break;
  104. case password_password_edit:
  105. Edit_GetText(hwndCtl, _tszPassword, ARRAYLEN(_tszPassword));
  106. break;
  107. case password_confirm_edit:
  108. Edit_GetText(hwndCtl,
  109. _tszConfirmPassword,
  110. ARRAYLEN(_tszConfirmPassword));
  111. break;
  112. }
  113. _UpdateWizButtons();
  114. }
  115. else
  116. {
  117. lr = 1;
  118. }
  119. return lr;
  120. }
  121. //+--------------------------------------------------------------------------
  122. //
  123. // Member: CPasswordPage::_OnInitDialog
  124. //
  125. // Synopsis: Perform initialization that should only occur once.
  126. //
  127. // Arguments: [lParam] - LPPROPSHEETPAGE used to create this page
  128. //
  129. // Returns: TRUE (let windows set focus)
  130. //
  131. // History: 5-20-1997 DavidMun Created
  132. //
  133. //---------------------------------------------------------------------------
  134. LRESULT
  135. CPasswordPage::_OnInitDialog(
  136. LPARAM lParam)
  137. {
  138. TRACE_METHOD(CPasswordPage, _OnInitDialog);
  139. Edit_LimitText(_hCtrl(password_name_edit), MAX_PATH);
  140. Edit_LimitText(_hCtrl(password_password_edit), REAL_PWLEN);
  141. Edit_LimitText(_hCtrl(password_confirm_edit), REAL_PWLEN);
  142. GetDefaultDomainAndUserName(_tszUserName, ARRAYLEN(_tszUserName));
  143. Edit_SetText(_hCtrl(password_name_edit), _tszUserName);
  144. return TRUE;
  145. }
  146. //+--------------------------------------------------------------------------
  147. //
  148. // Member: CPasswordPage::_OnPSNSetActive
  149. //
  150. // Synopsis: Enable the Next button iff this page's data is valid
  151. //
  152. // History: 5-20-1997 DavidMun Created
  153. //
  154. //---------------------------------------------------------------------------
  155. LRESULT
  156. CPasswordPage::_OnPSNSetActive(
  157. LPARAM lParam)
  158. {
  159. _UpdateWizButtons();
  160. return CPropPage::_OnPSNSetActive(lParam);
  161. }
  162. //===========================================================================
  163. //
  164. // CWizPage overrides
  165. //
  166. //===========================================================================
  167. //+--------------------------------------------------------------------------
  168. //
  169. // Member: CPasswordPage::_OnWizBack
  170. //
  171. // Synopsis: Set the current page to the selected trigger page
  172. //
  173. // History: 5-20-1997 DavidMun Created
  174. //
  175. //---------------------------------------------------------------------------
  176. LRESULT
  177. CPasswordPage::_OnWizBack()
  178. {
  179. TRACE_METHOD(CPasswordPage, _OnWizBack);
  180. SecureZeroMemory(_tszPassword, (MAX_PATH + 1) * sizeof(WCHAR));
  181. SecureZeroMemory(_tszConfirmPassword, (MAX_PATH) + 1 * sizeof(WCHAR));
  182. ULONG iddPage = GetSelectTriggerPage(_pParent)->GetSelectedTriggerPageID();
  183. SetWindowLongPtr(Hwnd(), DWLP_MSGRESULT, iddPage);
  184. return -1;
  185. }
  186. //===========================================================================
  187. //
  188. // CPasswordPage methods
  189. //
  190. //===========================================================================
  191. //+--------------------------------------------------------------------------
  192. //
  193. // Member: CPasswordPage::_UpdateWizButtons
  194. //
  195. // Synopsis: Enable the Next button iff this page's data is valid.
  196. //
  197. // History: 5-20-1997 DavidMun Created
  198. //
  199. //---------------------------------------------------------------------------
  200. VOID
  201. CPasswordPage::_UpdateWizButtons()
  202. {
  203. if (*_tszUserName && // name nonempty
  204. !lstrcmp(_tszPassword, _tszConfirmPassword)) // pwd == confirm
  205. {
  206. _SetWizButtons(PSWIZB_BACK | PSWIZB_NEXT);
  207. }
  208. else
  209. {
  210. _SetWizButtons(PSWIZB_BACK);
  211. }
  212. }