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.

229 lines
5.8 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. MessagePage.cpp
  5. Abstract:
  6. Functions for "Message" page of the wizard.
  7. Author:
  8. Sergey Kuzin (a-skuzin@microsoft.com) 09-August-1999
  9. Environment:
  10. Revision History:
  11. --*/
  12. #include "tsverui.h"
  13. #include "resource.h"
  14. #define MAX_TITLE_LEN 32
  15. void OnNext(HWND hwndDlg, LPSHAREDWIZDATA pdata);
  16. /*++
  17. Routine Description :
  18. dialog box procedure for the "Message" page.
  19. Arguments :
  20. IN HWND hwndDlg - handle to dialog box.
  21. IN UINT uMsg - message to be acted upon.
  22. IN WPARAM wParam - value specific to wMsg.
  23. IN LPARAM lParam - value specific to wMsg.
  24. Return Value :
  25. TRUE if it processed the message
  26. FALSE if it did not.
  27. --*/
  28. INT_PTR CALLBACK
  29. MessagePageProc (
  30. HWND hwndDlg,
  31. UINT uMsg,
  32. WPARAM wParam,
  33. LPARAM lParam)
  34. {
  35. static HWND hwndFrame=NULL; // IDC_STATIC_FRAME
  36. static HWND hwndStaticTitle=NULL; // IDC_STATIC_TITLE
  37. static HWND hwndEditTitle=NULL; // IDC_EDIT_TITLE
  38. static HWND hwndStaticMsg=NULL; // IDC_STATIC_MSG
  39. static HWND hwndEditMsg=NULL; // IDC_EDIT_MSG
  40. //Retrieve the shared user data from GWL_USERDATA
  41. LPSHAREDWIZDATA pdata = (LPSHAREDWIZDATA) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
  42. switch (uMsg)
  43. {
  44. case WM_INITDIALOG :
  45. {
  46. //Get the shared data from PROPSHEETPAGE lParam value
  47. //and load it into GWL_USERDATA
  48. pdata = (LPSHAREDWIZDATA) ((LPPROPSHEETPAGE) lParam) -> lParam;
  49. SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (DWORD_PTR) pdata);
  50. //get control handlers
  51. hwndFrame = GetDlgItem(hwndDlg, IDC_STATIC_FRAME);
  52. hwndStaticTitle = GetDlgItem(hwndDlg, IDC_STATIC_TITLE);
  53. hwndEditTitle = GetDlgItem(hwndDlg, IDC_EDIT_TITLE);
  54. hwndStaticMsg = GetDlgItem(hwndDlg, IDC_STATIC_MSG);
  55. hwndEditMsg = GetDlgItem(hwndDlg, IDC_EDIT_MSG);
  56. // controls for custom message
  57. if (CheckForRegKey(HKEY_USERS, szConstraintsKeyPath,KeyName[USE_MSG]))
  58. {
  59. EnableWindow(hwndFrame, TRUE);
  60. EnableWindow(hwndStaticTitle, TRUE);
  61. EnableWindow(hwndEditTitle, TRUE);
  62. EnableWindow(hwndStaticMsg, TRUE);
  63. EnableWindow(hwndEditMsg, TRUE);
  64. CheckDlgButton(hwndDlg, IDC_ENABLE_MSG, TRUE);
  65. } else {
  66. CheckDlgButton(hwndDlg, IDC_ENABLE_MSG, FALSE);
  67. EnableWindow(hwndFrame, FALSE);
  68. EnableWindow(hwndStaticTitle, FALSE);
  69. EnableWindow(hwndEditTitle, FALSE);
  70. EnableWindow(hwndStaticMsg, FALSE);
  71. EnableWindow(hwndEditMsg, FALSE);
  72. }
  73. LPTSTR szBuf=NULL;
  74. szBuf=GetRegString(HKEY_USERS, szConstraintsKeyPath, KeyName[MSG]);
  75. if(szBuf){
  76. SetWindowText(hwndEditMsg,szBuf);
  77. delete szBuf;
  78. szBuf=NULL;
  79. }
  80. szBuf=GetRegString(HKEY_USERS, szConstraintsKeyPath, KeyName[MSG_TITLE]);
  81. if(szBuf){
  82. SetWindowText(hwndEditTitle,szBuf);
  83. delete szBuf;
  84. szBuf=NULL;
  85. }
  86. break;
  87. }
  88. case WM_NOTIFY :
  89. {
  90. LPNMHDR lpnm = (LPNMHDR) lParam;
  91. switch (lpnm->code)
  92. {
  93. case PSN_SETACTIVE : //Enable the Next button
  94. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  95. if(pdata->pszMessageTitle){
  96. delete pdata->pszMessageTitle;
  97. pdata->pszMessageTitle=NULL;
  98. }
  99. if(pdata->pszMessageText){
  100. delete pdata->pszMessageText;
  101. pdata->pszMessageText=NULL;
  102. }
  103. break;
  104. case PSN_WIZNEXT :
  105. //Handle a Next button click here
  106. OnNext(hwndDlg, pdata);
  107. break;
  108. case PSN_RESET :
  109. //Handle a Cancel button click, if necessary
  110. break;
  111. default :
  112. break;
  113. }
  114. }
  115. break;
  116. case WM_COMMAND:
  117. switch ( LOWORD(wParam) ) {
  118. case IDC_ENABLE_MSG:
  119. if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_MSG)){
  120. EnableWindow(hwndFrame, TRUE);
  121. EnableWindow(hwndStaticTitle, TRUE);
  122. EnableWindow(hwndEditTitle, TRUE);
  123. EnableWindow(hwndStaticMsg, TRUE);
  124. EnableWindow(hwndEditMsg, TRUE);
  125. } else {
  126. EnableWindow(hwndFrame, FALSE);
  127. EnableWindow(hwndStaticTitle, FALSE);
  128. EnableWindow(hwndEditTitle, FALSE);
  129. EnableWindow(hwndStaticMsg, FALSE);
  130. EnableWindow(hwndEditMsg, FALSE);
  131. }
  132. break;
  133. default:
  134. break;
  135. }
  136. break;
  137. default:
  138. break;
  139. }
  140. return FALSE;
  141. }
  142. /*++
  143. Routine Description :
  144. Fills data structure with values from controls.
  145. Arguments :
  146. IN HWND hwndDlg - Page handle.
  147. LPSHAREDWIZDATA pdata - pointer to data structure
  148. Return Value :
  149. none
  150. --*/
  151. void OnNext(HWND hwndDlg, LPSHAREDWIZDATA pdata)
  152. {
  153. if(IsDlgButtonChecked(hwndDlg, IDC_ENABLE_MSG)==BST_CHECKED){
  154. pdata->bMessageEnabled=TRUE;
  155. }else{
  156. pdata->bMessageEnabled=FALSE;
  157. }
  158. TCHAR szBuf[MAX_LEN+1];
  159. int Size;
  160. Size=GetDlgItemText(hwndDlg, IDC_EDIT_TITLE, szBuf, MAX_LEN);
  161. if (Size){
  162. pdata->pszMessageTitle=new TCHAR[Size+1];
  163. if (pdata->pszMessageTitle != NULL) {
  164. _tcscpy(pdata->pszMessageTitle,szBuf);
  165. }
  166. }
  167. Size=GetDlgItemText(hwndDlg, IDC_EDIT_MSG, szBuf, MAX_LEN);
  168. if (Size){
  169. pdata->pszMessageText=new TCHAR[Size+1];
  170. if (pdata->pszMessageText) {
  171. _tcscpy(pdata->pszMessageText,szBuf);
  172. }
  173. }
  174. }