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.

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