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.

215 lines
6.5 KiB

  1. // Created 04-Jan-1993 1:10pm by Jeff Parsons
  2. #include "shellprv.h"
  3. #pragma hdrstop
  4. BINF abinfVid[] = {
  5. {IDC_WINDOWED, BITNUM(VID_FULLSCREEN) | 0x80},
  6. {IDC_FULLSCREEN, BITNUM(VID_FULLSCREEN)},
  7. {IDC_TEXTEMULATE, BITNUM(VID_TEXTEMULATE)},
  8. {IDC_DYNAMICVIDMEM, BITNUM(VID_RETAINMEMORY) | 0x80},
  9. };
  10. BINF abinfWinInit[] = {
  11. {IDC_WINRESTORE, BITNUM(WININIT_NORESTORE) | 0x80},
  12. };
  13. // Private function prototypes
  14. void EnableVidDlg(HWND hDlg, PPROPLINK ppl);
  15. void InitVidDlg(HWND hDlg, PPROPLINK ppl);
  16. void ApplyVidDlg(HWND hDlg, PPROPLINK ppl);
  17. // Context-sensitive help ids
  18. const static DWORD rgdwHelp[] = {
  19. IDC_SCREENUSAGEGRP, IDH_COMM_GROUPBOX,
  20. IDC_FULLSCREEN, IDH_DOS_SCREEN_USAGE_FULL,
  21. IDC_WINDOWED, IDH_DOS_SCREEN_USAGE_WINDOW,
  22. IDC_SCREENLINESLBL, IDH_DOS_DISPLAY_SCREEN_SETTINGS,
  23. IDC_SCREENLINES, IDH_DOS_DISPLAY_SCREEN_SETTINGS,
  24. IDC_WINDOWUSAGEGRP, IDH_COMM_GROUPBOX,
  25. IDC_TOOLBAR, IDH_DOS_WINDOWS_TOOLBAR,
  26. IDC_SCREENPERFGRP, IDH_COMM_GROUPBOX,
  27. IDC_TEXTEMULATE, IDH_DOS_DISPLAY_ROM,
  28. IDC_WINRESTORE, IDH_DOS_SCREEN_RESTORE,
  29. IDC_DYNAMICVIDMEM, IDH_DOS_SCREEN_DMA,
  30. IDC_REALMODEDISABLE,IDH_DOS_REALMODEPROPS,
  31. 0, 0
  32. };
  33. /*
  34. * This is a little table that converts listbox indices into
  35. * screen lines.
  36. *
  37. * The correspondences are...
  38. *
  39. * IDS_WHATEVER = List box index + IDS_DEFAULTLINES
  40. * nLines = awVideoLines[List box index]
  41. */
  42. #if IDS_25LINES - IDS_DEFAULTLINES != 1 || \
  43. IDS_43LINES - IDS_DEFAULTLINES != 2 || \
  44. IDS_50LINES - IDS_DEFAULTLINES != 3
  45. #error Manifest constants damaged.
  46. #endif
  47. WORD awVideoLines[] = { 0, 25, 43, 50 };
  48. BOOL_PTR CALLBACK DlgVidProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  49. {
  50. PPROPLINK ppl;
  51. FunctionName(DlgVidProc);
  52. ppl = (PPROPLINK)GetWindowLongPtr(hDlg, DWLP_USER);
  53. switch (uMsg) {
  54. case WM_INITDIALOG:
  55. lParam = ((LPPROPSHEETPAGE)lParam)->lParam;
  56. SetWindowLongPtr(hDlg, DWLP_USER, lParam);
  57. ppl = (PPROPLINK)(INT_PTR)lParam;
  58. InitVidDlg(hDlg, ppl);
  59. break;
  60. HELP_CASES(rgdwHelp) // Handle help messages
  61. case WM_COMMAND:
  62. if (LOWORD(lParam) == 0)
  63. break; // message not from a control
  64. switch (LOWORD(wParam)) {
  65. case IDC_SCREENLINES:
  66. if (HIWORD(wParam) == CBN_SELCHANGE)
  67. SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)hDlg, 0L);
  68. break;
  69. case IDC_WINDOWED:
  70. case IDC_FULLSCREEN:
  71. case IDC_WINRESTORE:
  72. case IDC_TEXTEMULATE:
  73. case IDC_DYNAMICVIDMEM:
  74. if (HIWORD(wParam) == BN_CLICKED)
  75. SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)hDlg, 0L);
  76. break;
  77. }
  78. break;
  79. case WM_NOTIFY:
  80. switch (((NMHDR *)lParam)->code) {
  81. case PSN_SETACTIVE:
  82. AdjustRealModeControls(ppl, hDlg);
  83. break;
  84. case PSN_KILLACTIVE:
  85. // This gives the current page a chance to validate itself
  86. // SetWindowLong(hDlg, DWL_MSGRESULT, 0);
  87. break;
  88. case PSN_APPLY:
  89. // This happens on OK....
  90. ApplyVidDlg(hDlg, ppl);
  91. break;
  92. case PSN_RESET:
  93. // This happens on Cancel....
  94. break;
  95. }
  96. break;
  97. default:
  98. return FALSE; // return 0 when not processing
  99. }
  100. return TRUE;
  101. }
  102. void InitVidDlg(HWND hDlg, PPROPLINK ppl)
  103. {
  104. WORD w;
  105. HWND hwnd;
  106. PROPVID vid;
  107. PROPWIN win;
  108. TCHAR szBuf[MAX_STRING_SIZE];
  109. FunctionName(InitVidDlg);
  110. if (!PifMgr_GetProperties(ppl, MAKELP(0,GROUP_VID),
  111. &vid, SIZEOF(vid), GETPROPS_NONE) ||
  112. !PifMgr_GetProperties(ppl, MAKELP(0,GROUP_WIN),
  113. &win, SIZEOF(win), GETPROPS_NONE)) {
  114. Warning(hDlg, IDS_QUERY_ERROR, MB_ICONEXCLAMATION | MB_OK);
  115. return;
  116. }
  117. SetDlgBits(hDlg, &abinfVid[0], ARRAYSIZE(abinfVid), vid.flVid);
  118. SetDlgBits(hDlg, &abinfWinInit[0], ARRAYSIZE(abinfWinInit), win.flWinInit);
  119. /*
  120. * Fill in the "Initial screen size" combo box. Note that
  121. * we bail on low-memory errors. Note also that if we have
  122. * a nonstandard size, we just leave the combo box with no
  123. * default selection.
  124. */
  125. VERIFYTRUE(hwnd = GetDlgItem(hDlg, IDC_SCREENLINES));
  126. for (w = 0; w < ARRAYSIZE(awVideoLines); w++) {
  127. VERIFYTRUE(LoadString(HINST_THISDLL, IDS_DEFAULTLINES + w, szBuf, ARRAYSIZE(szBuf)));
  128. VERIFYTRUE(SendMessage(hwnd, CB_ADDSTRING, 0, (LPARAM)(LPTSTR)szBuf) == w);
  129. if (vid.cScreenLines == awVideoLines[w]) {
  130. SendMessage(hwnd, CB_SETCURSEL, w, 0);
  131. }
  132. }
  133. if (!IsBilingualCP(g_uCodePage))
  134. {
  135. EnableWindow(GetDlgItem(hDlg, IDC_SCREENLINESLBL), FALSE);
  136. EnableWindow(hwnd, FALSE);
  137. }
  138. }
  139. void ApplyVidDlg(HWND hDlg, PPROPLINK ppl)
  140. {
  141. DWORD dw;
  142. HWND hwnd;
  143. PROPVID vid;
  144. PROPWIN win;
  145. FunctionName(ApplyVidDlg);
  146. // Get the current set of properties, then overlay the new settings
  147. if (!PifMgr_GetProperties(ppl, MAKELP(0,GROUP_VID),
  148. &vid, SIZEOF(vid), GETPROPS_NONE) ||
  149. !PifMgr_GetProperties(ppl, MAKELP(0,GROUP_WIN),
  150. &win, SIZEOF(win), GETPROPS_NONE)) {
  151. Warning(hDlg, IDS_UPDATE_ERROR, MB_ICONEXCLAMATION | MB_OK);
  152. return;
  153. }
  154. GetDlgBits(hDlg, &abinfVid[0], ARRAYSIZE(abinfVid), &vid.flVid);
  155. GetDlgBits(hDlg, &abinfWinInit[0], ARRAYSIZE(abinfWinInit), &win.flWinInit);
  156. /*
  157. * If there is no current selection, don't change the cScreenLines
  158. * property. This allows the user to retain an unusual number of
  159. * screen lines by simply not touching the field.
  160. */
  161. VERIFYTRUE(hwnd = GetDlgItem(hDlg, IDC_SCREENLINES));
  162. dw = (DWORD) SendMessage(hwnd, CB_GETCURSEL, 0, 0L);
  163. if (dw < ARRAYSIZE(awVideoLines)) {
  164. vid.cScreenLines = awVideoLines[dw];
  165. }
  166. if (!PifMgr_SetProperties(ppl, MAKELP(0,GROUP_VID),
  167. &vid, SIZEOF(vid), SETPROPS_NONE) ||
  168. !PifMgr_SetProperties(ppl, MAKELP(0,GROUP_WIN),
  169. &win, SIZEOF(win), SETPROPS_NONE))
  170. Warning(hDlg, IDS_UPDATE_ERROR, MB_ICONEXCLAMATION | MB_OK);
  171. else
  172. if (ppl->hwndNotify) {
  173. ppl->flProp |= PROP_NOTIFY;
  174. PostMessage(ppl->hwndNotify, ppl->uMsgNotify, SIZEOF(vid), (LPARAM)MAKELP(0,GROUP_VID));
  175. PostMessage(ppl->hwndNotify, ppl->uMsgNotify, SIZEOF(win), (LPARAM)MAKELP(0,GROUP_WIN));
  176. }
  177. }