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.

247 lines
5.5 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1996.
  5. //
  6. // File: nameit.cxx
  7. //
  8. // Contents: Task wizard naming property page implementation.
  9. //
  10. // Classes: CNameItPage
  11. //
  12. // History: 11-21-1997 SusiA
  13. //
  14. //---------------------------------------------------------------------------
  15. #include "precomp.h"
  16. extern OSVERSIONINFOA g_OSVersionInfo; // osVersionInfo,
  17. extern LANGID g_LangIdSystem; // LangId of system we are running on.
  18. CNameItPage *g_pNameItPage = NULL;
  19. extern CSelectDailyPage *g_pDailyPage;
  20. //+-------------------------------------------------------------------------------
  21. // FUNCTION: SchedWizardNameItDlgProc(HWND, UINT, WPARAM, LPARAM)
  22. //
  23. // PURPOSE: Callback dialog procedure for the property page
  24. //
  25. // PARAMETERS:
  26. // hDlg - Dialog box window handle
  27. // uMessage - current message
  28. // wParam - depends on message
  29. // lParam - depends on message
  30. //
  31. // RETURN VALUE:
  32. //
  33. // Depends on message. In general, return TRUE if we process it.
  34. //
  35. // COMMENTS:
  36. //
  37. //+-------------------------------------------------------------------------------
  38. BOOL CALLBACK SchedWizardNameItDlgProc(HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
  39. {
  40. switch (uMessage)
  41. {
  42. case WM_INITDIALOG:
  43. {
  44. if (g_pNameItPage)
  45. g_pNameItPage->Initialize(hDlg);
  46. //This handles the 256 color processing init
  47. //for the .bmp
  48. InitPage(hDlg,lParam);
  49. }
  50. break;
  51. case WM_PAINT:
  52. WmPaint(hDlg, uMessage, wParam, lParam);
  53. break;
  54. case WM_PALETTECHANGED:
  55. WmPaletteChanged(hDlg, wParam);
  56. break;
  57. case WM_QUERYNEWPALETTE:
  58. return( WmQueryNewPalette(hDlg) );
  59. break;
  60. case WM_ACTIVATE:
  61. return( WmActivate(hDlg, wParam, lParam) );
  62. break;
  63. case WM_DESTROY:
  64. {
  65. Unload256ColorBitmap();
  66. }
  67. break;
  68. case WM_NOTIFY:
  69. switch (((NMHDR FAR *) lParam)->code)
  70. {
  71. case PSN_KILLACTIVE:
  72. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, FALSE);
  73. return 1;
  74. break;
  75. case PSN_RESET:
  76. // reset to the original values
  77. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, FALSE);
  78. break;
  79. case PSN_SETACTIVE:
  80. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_NEXT);
  81. break;
  82. case PSN_WIZNEXT:
  83. if (g_pNameItPage)
  84. {
  85. if (!g_pNameItPage->SetScheduleName())
  86. {
  87. SchedUIErrorDialog(hDlg, IERR_INVALIDSCHEDNAME);
  88. // reset to the original values
  89. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  90. break;
  91. }
  92. }
  93. if (g_pDailyPage)
  94. {
  95. g_pDailyPage->SetITrigger();
  96. }
  97. break;
  98. default:
  99. return FALSE;
  100. }
  101. break;
  102. default:
  103. return FALSE;
  104. }
  105. return TRUE;
  106. }
  107. //+--------------------------------------------------------------------------
  108. //
  109. // Member: CNameItPage::CNameItPage
  110. //
  111. // Synopsis: ctor
  112. //
  113. // [phPSP] - filled with prop page handle
  114. //
  115. // History: 11-21-1997 SusiA Stole from Task Scheduler wizard
  116. //
  117. //---------------------------------------------------------------------------
  118. CNameItPage::CNameItPage(
  119. HINSTANCE hinst,
  120. ISyncSchedule *pISyncSched,
  121. HPROPSHEETPAGE *phPSP)
  122. {
  123. ZeroMemory(&m_psp, sizeof(PROPSHEETPAGE));
  124. g_pNameItPage = this;
  125. m_psp.dwSize = sizeof (PROPSHEETPAGE);
  126. m_psp.hInstance = hinst;
  127. m_psp.dwFlags = PSP_DEFAULT;
  128. m_psp.pszTemplate = MAKEINTRESOURCE(IDD_SCHEDWIZ_NAMEIT);
  129. m_psp.pszIcon = NULL;
  130. m_psp.pfnDlgProc = (DLGPROC) SchedWizardNameItDlgProc;
  131. m_psp.lParam = 0;
  132. m_pISyncSched = pISyncSched;
  133. m_pISyncSched->AddRef();
  134. #ifdef WIZARD97
  135. m_psp.dwFlags |= PSP_HIDEHEADER;
  136. #endif // WIZARD97
  137. *phPSP = CreatePropertySheetPage(&m_psp);
  138. }
  139. //+--------------------------------------------------------------------------
  140. //
  141. // Member: CNameItPage::Initialize(HWND hwnd)
  142. //
  143. // Synopsis: initialize the name it page and set the task name to a unique
  144. // new onestop name
  145. //
  146. // History: 11-21-1997 SusiA
  147. //
  148. //---------------------------------------------------------------------------
  149. BOOL CNameItPage::Initialize(HWND hwnd)
  150. {
  151. WCHAR pwszNewName[MAX_PATH+1];
  152. #ifndef _UNICODE
  153. TCHAR ptszNewName[MAX_PATH+1];
  154. #else
  155. TCHAR *ptszNewName;
  156. #endif // _UNICODE
  157. DWORD dwSize = MAX_PATH;
  158. m_hwnd = hwnd;
  159. m_pISyncSched->GetScheduleName(&dwSize, pwszNewName);
  160. #ifndef _UNICODE
  161. ConvertString(ptszNewName, pwszNewName, MAX_PATH);
  162. #else
  163. ptszNewName = pwszNewName;
  164. #endif
  165. HWND hwndEdit = GetDlgItem(m_hwnd, IDC_NAMEIT);
  166. // IE5 doesn't setup edit controls properly, review
  167. SetCtrlFont(hwndEdit,g_OSVersionInfo.dwPlatformId,g_LangIdSystem);
  168. // set the limit on the edit box for entering the name
  169. SendMessage(hwndEdit,EM_SETLIMITTEXT,MAX_PATH,0);
  170. Edit_SetText(hwndEdit, ptszNewName);
  171. return TRUE;
  172. }
  173. //+--------------------------------------------------------------------------
  174. //
  175. // Member: BOOL CNameItPage::SetScheduleName()
  176. //
  177. // Synopsis: create a new schedule
  178. //
  179. // History: 11-21-1997 SusiA
  180. //
  181. //---------------------------------------------------------------------------
  182. BOOL CNameItPage::SetScheduleName()
  183. {
  184. WCHAR pwszNewName[MAX_PATH+1];
  185. HWND hwndEdit = GetDlgItem(m_hwnd, IDC_NAMEIT);
  186. Edit_GetText(hwndEdit, pwszNewName, MAX_PATH);
  187. if (S_OK == m_pISyncSched->SetScheduleName(pwszNewName))
  188. {
  189. return TRUE;
  190. }
  191. return FALSE;
  192. }