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.

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