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.

221 lines
4.9 KiB

  1. //Copyright (c) 1997-2000 Microsoft Corporation
  2. #include "pch.hxx" // pch
  3. #pragma hdrstop
  4. #include "resource.h"
  5. #include "pgLokPrv.h"
  6. CLookPreviewPg::CLookPreviewPg(
  7. LPPROPSHEETPAGE ppsp,
  8. int dwPageId,
  9. int nIdTitle,
  10. int nIdSubTitle,
  11. int nIdValueString
  12. ) : WizardPage(ppsp, nIdTitle, nIdSubTitle)
  13. {
  14. m_dwPageId = dwPageId;
  15. ppsp->pszTemplate = MAKEINTRESOURCE(m_dwPageId);
  16. m_nIdValueString = nIdValueString;
  17. m_nCountValues = 0;
  18. m_nCurValueIndex = 0;
  19. m_nOrigValueIndex = 0;
  20. m_hwndSlider = 0;
  21. m_hwndListBox = 0;
  22. }
  23. CLookPreviewPg::~CLookPreviewPg(
  24. VOID
  25. )
  26. {
  27. }
  28. #include "LookPrev.h"
  29. void PASCAL Look_RebuildSysStuff(BOOL fInit);
  30. void SetMyNonClientMetrics(LPNONCLIENTMETRICS lpncm);
  31. LRESULT
  32. CLookPreviewPg::OnInitDialog(
  33. HWND hwnd,
  34. WPARAM wParam,
  35. LPARAM lParam
  36. )
  37. {
  38. SendMessage(GetDlgItem(m_hwnd, IDC_LOOKPREV), LPM_RECALC, 0, 0);
  39. SendMessage(GetDlgItem(m_hwnd, IDC_LOOKPREV), LPM_REPAINT, 0, 0);
  40. LoadValueArray();
  41. m_hwndListBox = GetDlgItem(m_hwnd, IDC_PREVLIST);
  42. // Get the initial value for the type of preview we are doing
  43. int nCurrentSize = GetCurrentValue(NULL/*&g_Options.m_schemePreview.m_ncm*/);
  44. // Find next larger
  45. for(int i=m_nCountValues - 1;i>=0;i--)
  46. {
  47. if(m_rgnValues[i] >= nCurrentSize)
  48. m_nCurValueIndex = i;
  49. else break;
  50. }
  51. m_nOrigValueIndex = m_nCurValueIndex;
  52. // Initialize the high contrast colors listbox
  53. for(i=0;i<m_nCountValues;i++)
  54. {
  55. TCHAR sz[100];
  56. GetValueItemText(i, sz, ARRAYSIZE(sz));
  57. ListBox_AddString(m_hwndListBox, sz);
  58. }
  59. ListBox_SetCurSel(m_hwndListBox, m_nCurValueIndex);
  60. UpdateControls();
  61. return 1;
  62. }
  63. void CLookPreviewPg::LoadValueArray()
  64. {
  65. LoadArrayFromStringTable(m_nIdValueString, m_rgnValues, &m_nCountValues);
  66. }
  67. void CLookPreviewPg::UpdateControls()
  68. {
  69. }
  70. LRESULT
  71. CLookPreviewPg::OnCommand(
  72. HWND hwnd,
  73. WPARAM wParam,
  74. LPARAM lParam
  75. )
  76. {
  77. LRESULT lResult = 1;
  78. WORD wNotifyCode = HIWORD(wParam);
  79. WORD wCtlID = LOWORD(wParam);
  80. HWND hwndCtl = (HWND)lParam;
  81. switch(wCtlID)
  82. {
  83. case IDC_PREVLIST:
  84. switch(wNotifyCode)
  85. {
  86. case LBN_SELCHANGE:
  87. UpdatePreview(wCtlID);
  88. break;
  89. default:
  90. break;
  91. }
  92. break;
  93. default:
  94. break;
  95. }
  96. return lResult;
  97. }
  98. void CLookPreviewPg::ResetColors()
  99. {
  100. if(0 != m_nCurValueIndex)
  101. {
  102. int nCount = GetScheme(m_nCurValueIndex-1).nColorsUsed;
  103. for(int i=0;i<nCount;i++)
  104. {
  105. g_Options.m_schemePreview.m_rgb[i] = GetScheme(m_nCurValueIndex-1).rgb[i];
  106. }
  107. }
  108. else
  109. {
  110. // Use scheme that we came in here with
  111. g_Options.RestoreOriginalColorsToPreview();
  112. }
  113. Look_RebuildSysStuff(TRUE);
  114. SendMessage(GetDlgItem(m_hwnd, IDC_LOOKPREV), LPM_REPAINT, 0, 0);
  115. }
  116. LRESULT
  117. CLookPreviewPg::HandleMsg(
  118. HWND hwnd,
  119. UINT uMsg,
  120. WPARAM wParam,
  121. LPARAM lParam
  122. )
  123. {
  124. return 0;
  125. }
  126. void CLookPreviewPg::UpdatePreview(int nActionCtl)
  127. {
  128. // Calculate new index based on the control that generated this event
  129. switch(nActionCtl)
  130. {
  131. case IDC_PREVLIST:
  132. m_nCurValueIndex = ListBox_GetCurSel(m_hwndListBox);
  133. break;
  134. default:
  135. break;
  136. }
  137. // Make sure we are withing range
  138. m_nCurValueIndex = max(m_nCurValueIndex, 0);
  139. m_nCurValueIndex = min(m_nCurValueIndex, m_nCountValues - 1);
  140. // Modify the ncm structure
  141. // JMC: The wizard currently does not muck with m_ncm any more - we only change the colors
  142. // Therefore, we can call ModifyMyNonClientMetrics() with a dummy variable
  143. NONCLIENTMETRICS ncmDummy;
  144. ModifyMyNonClientMetrics(ncmDummy/*g_Options.m_schemePreview.m_ncm*/);
  145. if (m_nCurValueIndex == 0)
  146. {
  147. // If we are here the user is going "back" and we revert to "Windows Classic" (Why?)
  148. LoadString(g_hInstDll, IDS_SCHEME_CURRENTCOLORSCHEME+100, g_Options.m_schemePreview.m_szSelectedStyle, MAX_NUM_SZ);
  149. }
  150. else
  151. {
  152. lstrcpy(g_Options.m_schemePreview.m_szSelectedStyle, GetScheme(m_nCurValueIndex-1).szNameIndexId);
  153. }
  154. Look_RebuildSysStuff(TRUE);
  155. SendMessage(GetDlgItem(m_hwnd, IDC_LOOKPREV), LPM_RECALC, 0, 0);
  156. SendMessage(GetDlgItem(m_hwnd, IDC_LOOKPREV), LPM_REPAINT, 0, 0);
  157. }
  158. LRESULT
  159. CLookPreviewPg::OnPSN_WizNext(
  160. HWND hwnd,
  161. INT idCtl,
  162. LPPSHNOTIFY pnmh
  163. )
  164. {
  165. if (m_nOrigValueIndex != m_nCurValueIndex)
  166. {
  167. // we are applying the preview; clear theme and wallpaper
  168. // so visual style gets turned off before we make the change.
  169. if (m_nCurValueIndex)
  170. {
  171. g_Options.m_schemePreview.ClearTheme();
  172. g_Options.m_schemePreview.ClearWallpaper();
  173. }
  174. else
  175. {
  176. memcpy(&g_Options.m_schemePreview, &g_Options.m_schemeOriginal, sizeof(WIZSCHEME));
  177. }
  178. g_Options.ApplyPreview();
  179. m_nOrigValueIndex = m_nCurValueIndex;
  180. }
  181. return WizardPage::OnPSN_WizNext(hwnd, idCtl, pnmh);
  182. }