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.

230 lines
7.1 KiB

  1. // Created 04-Jan-1993 1:10pm by Jeff Parsons
  2. #include "shellprv.h"
  3. #pragma hdrstop
  4. #define VMD_DEVICE_ID 0x0000C
  5. BINF abinfTsk[] = {
  6. {IDC_FGNDSCRNSAVER, BITNUM(TSK_NOSCREENSAVER) | 0x80},
  7. {IDC_BGNDSUSPEND, BITNUM(TSK_BACKGROUND) | 0x80},
  8. {IDC_WARNTERMINATE, BITNUM(TSK_NOWARNTERMINATE)| 0x80},
  9. };
  10. BINF abinfKbd[] = {
  11. {IDC_ALTESC, BITNUM(KBD_NOALTESC) | 0x80},
  12. {IDC_ALTTAB, BITNUM(KBD_NOALTTAB) | 0x80},
  13. {IDC_CTRLESC, BITNUM(KBD_NOCTRLESC) | 0x80},
  14. {IDC_PRTSC, BITNUM(KBD_NOPRTSC) | 0x80},
  15. {IDC_ALTPRTSC, BITNUM(KBD_NOALTPRTSC) | 0x80},
  16. {IDC_ALTSPACE, BITNUM(KBD_NOALTSPACE) | 0x80},
  17. {IDC_ALTENTER, BITNUM(KBD_NOALTENTER) | 0x80},
  18. {IDC_FASTPASTE, BITNUM(KBD_FASTPASTE) },
  19. };
  20. BINF abinfMse[] = {
  21. {IDC_QUICKEDIT, BITNUM(MSE_WINDOWENABLE)| 0x80},
  22. {IDC_EXCLMOUSE, BITNUM(MSE_EXCLUSIVE) }, // WARNING -- Assumed to be abinfMse[1] below
  23. };
  24. // Private function prototypes
  25. BOOL GetSetMscProps(HWND hDlg, GETSETFN lpfn, PPROPLINK ppl, LPPROPTSK lptsk, LPPROPKBD lpkbd, LPPROPMSE lpmse, LPPROPENV lpenv, int idError);
  26. void InitMscDlg(HWND hDlg, PPROPLINK ppl);
  27. void ApplyMscDlg(HWND hDlg, PPROPLINK ppl);
  28. // Context-sensitive help ids
  29. const static DWORD rgdwHelp[] = {
  30. IDC_FGNDGRP, IDH_COMM_GROUPBOX,
  31. IDC_FGNDSCRNSAVER, IDH_DOS_TASKING_ALLOW_SCREENSAVER,
  32. IDC_BGNDGRP, IDH_COMM_GROUPBOX,
  33. IDC_BGNDSUSPEND, IDH_DOS_TASKING_SUSPEND,
  34. IDC_IDLEGRP, IDH_COMM_GROUPBOX,
  35. IDC_IDLELOWLBL, IDH_DOS_TASKING_IDLE_SLIDER,
  36. IDC_IDLEHIGHLBL, IDH_DOS_TASKING_IDLE_SLIDER,
  37. IDC_IDLESENSE, IDH_DOS_TASKING_IDLE_SLIDER,
  38. IDC_TERMGRP, IDH_COMM_GROUPBOX,
  39. IDC_WARNTERMINATE, IDH_DOS_WINDOWS_WARN,
  40. IDC_MISCMOUSEGRP, IDH_COMM_GROUPBOX,
  41. IDC_QUICKEDIT, IDH_DOS_WINDOWS_MOUSE_QUICKEDIT,
  42. IDC_EXCLMOUSE, IDH_DOS_WINDOWS_MOUSE_EXCLUSIVE,
  43. IDC_ALTESC, IDH_DOS_KEYBOARD_SHORTCUTS,
  44. IDC_MISCKBDGRP, IDH_COMM_GROUPBOX,
  45. IDC_ALTTAB, IDH_DOS_KEYBOARD_SHORTCUTS,
  46. IDC_CTRLESC, IDH_DOS_KEYBOARD_SHORTCUTS,
  47. IDC_PRTSC, IDH_DOS_KEYBOARD_SHORTCUTS,
  48. IDC_ALTPRTSC, IDH_DOS_KEYBOARD_SHORTCUTS,
  49. IDC_ALTSPACE, IDH_DOS_KEYBOARD_SHORTCUTS,
  50. IDC_ALTENTER, IDH_DOS_KEYBOARD_SHORTCUTS,
  51. IDC_MISCOTHERGRP, IDH_COMM_GROUPBOX,
  52. IDC_FASTPASTE, IDH_DOS_KEYBOARD_FASTPASTE,
  53. IDC_TOOLBAR, IDH_DOS_WINDOWS_TOOLBAR,
  54. IDC_WINRESTORE, IDH_DOS_WINDOWS_RESTORE,
  55. IDC_REALMODEDISABLE, IDH_DOS_REALMODEPROPS,
  56. 0, 0
  57. };
  58. BOOL_PTR CALLBACK DlgMscProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  59. {
  60. PPROPLINK ppl;
  61. FunctionName(DlgMscProc);
  62. ppl = (PPROPLINK)GetWindowLongPtr(hDlg, DWLP_USER);
  63. switch (uMsg) {
  64. case WM_INITDIALOG:
  65. lParam = ((LPPROPSHEETPAGE)lParam)->lParam;
  66. SetWindowLongPtr(hDlg, DWLP_USER, lParam);
  67. ppl = (PPROPLINK)lParam;
  68. InitMscDlg(hDlg, ppl);
  69. break;
  70. HELP_CASES(rgdwHelp) // Handle help messages
  71. case WM_HSCROLL: // assumed to be notifications
  72. // from our one and only trackbar
  73. SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)hDlg, 0L);
  74. break;
  75. case WM_COMMAND:
  76. if (LOWORD(lParam) == 0)
  77. break; // message not from a control
  78. switch (LOWORD(wParam)) {
  79. case IDC_FGNDSCRNSAVER:
  80. case IDC_BGNDSUSPEND:
  81. case IDC_QUICKEDIT:
  82. case IDC_EXCLMOUSE:
  83. case IDC_WARNTERMINATE:
  84. case IDC_FASTPASTE:
  85. case IDC_INSTRUCTIONS:
  86. case IDC_ALTTAB:
  87. case IDC_CTRLESC:
  88. case IDC_ALTPRTSC:
  89. case IDC_ALTESC:
  90. case IDC_PRTSC:
  91. case IDC_ALTENTER:
  92. case IDC_ALTSPACE:
  93. if (HIWORD(wParam) == BN_CLICKED)
  94. SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)hDlg, 0L);
  95. break;
  96. }
  97. break;
  98. case WM_NOTIFY:
  99. switch (((NMHDR *)lParam)->code) {
  100. case PSN_KILLACTIVE:
  101. // This gives the current page a chance to validate itself
  102. // SetWindowLong(hDlg, DWL_MSGRESULT, 0);
  103. break;
  104. case PSN_APPLY:
  105. // This happens on OK....
  106. ApplyMscDlg(hDlg, ppl);
  107. break;
  108. case PSN_RESET:
  109. // This happens on Cancel....
  110. break;
  111. }
  112. break;
  113. case WM_WININICHANGE:
  114. case WM_SYSCOLORCHANGE:
  115. case WM_DISPLAYCHANGE:
  116. RelayMessageToChildren(hDlg, uMsg, wParam, lParam);
  117. break;
  118. default:
  119. return FALSE; // return 0 when not processing
  120. }
  121. return TRUE;
  122. }
  123. BOOL GetSetMscProps(HWND hDlg, GETSETFN lpfn, PPROPLINK ppl, LPPROPTSK lptsk, LPPROPKBD lpkbd, LPPROPMSE lpmse, LPPROPENV lpenv, int idError)
  124. {
  125. if (!(*lpfn)(ppl, MAKELP(0,GROUP_TSK),
  126. lptsk, sizeof(*lptsk), GETPROPS_NONE) ||
  127. !(*lpfn)(ppl, MAKELP(0,GROUP_KBD),
  128. lpkbd, sizeof(*lpkbd), GETPROPS_NONE) ||
  129. !(*lpfn)(ppl, MAKELP(0,GROUP_MSE),
  130. lpmse, sizeof(*lpmse), GETPROPS_NONE) ||
  131. !(*lpfn)(ppl, MAKELP(0,GROUP_ENV),
  132. lpenv, sizeof(*lpenv), GETPROPS_NONE)) {
  133. Warning(hDlg, (WORD)idError, (WORD)(MB_ICONEXCLAMATION | MB_OK));
  134. return FALSE;
  135. }
  136. return TRUE;
  137. }
  138. void InitMscDlg(HWND hDlg, PPROPLINK ppl)
  139. {
  140. PROPTSK tsk;
  141. PROPKBD kbd;
  142. PROPMSE mse;
  143. PROPENV env;
  144. FunctionName(InitMscDlg);
  145. if (!GetSetMscProps(hDlg, PifMgr_GetProperties, ppl, &tsk, &kbd, &mse, &env, IDS_QUERY_ERROR))
  146. return;
  147. SetDlgItemPct(hDlg, IDC_IDLESENSE, tsk.wIdleSensitivity);
  148. SetDlgBits(hDlg, &abinfTsk[0], ARRAYSIZE(abinfTsk), tsk.flTsk);
  149. SetDlgBits(hDlg, &abinfKbd[0], ARRAYSIZE(abinfKbd), kbd.flKbd);
  150. SetDlgBits(hDlg, &abinfMse[0], ARRAYSIZE(abinfMse), mse.flMse);
  151. }
  152. void ApplyMscDlg(HWND hDlg, PPROPLINK ppl)
  153. {
  154. PROPTSK tsk;
  155. PROPKBD kbd;
  156. PROPMSE mse;
  157. PROPENV env;
  158. FunctionName(ApplyMscDlg);
  159. if (!GetSetMscProps(hDlg, PifMgr_GetProperties, ppl, &tsk, &kbd, &mse, &env, IDS_UPDATE_ERROR))
  160. return;
  161. GetDlgBits(hDlg, &abinfTsk[0], ARRAYSIZE(abinfTsk), &tsk.flTsk);
  162. tsk.wIdleSensitivity = (WORD) GetDlgItemPct(hDlg, IDC_IDLESENSE);
  163. GetDlgBits(hDlg, &abinfKbd[0], ARRAYSIZE(abinfKbd), &kbd.flKbd);
  164. GetDlgBits(hDlg, &abinfMse[0], ARRAYSIZE(abinfMse), &mse.flMse);
  165. if (GetSetMscProps(hDlg, PifMgr_SetProperties, ppl, &tsk, &kbd, &mse, &env, IDS_UPDATE_ERROR)) {
  166. if (ppl->hwndNotify) {
  167. ppl->flProp |= PROP_NOTIFY;
  168. PostMessage(ppl->hwndNotify, ppl->uMsgNotify, sizeof(mse), (LPARAM)MAKELP(0,GROUP_MSE));
  169. }
  170. }
  171. }
  172. BOOL IsBufferDifferent( LPVOID lpBuff1, LPVOID lpBuff2, UINT cb )
  173. {
  174. BYTE bRet = 0;
  175. LPBYTE lpByte1 = (LPBYTE)lpBuff1;
  176. LPBYTE lpByte2 = (LPBYTE)lpBuff2;
  177. ASSERT(cb>0);
  178. while ((cb!=0) && (bRet==0))
  179. {
  180. bRet = *lpByte1 - *lpByte2;
  181. cb--;
  182. lpByte1++;
  183. lpByte2++;
  184. }
  185. return (DWORD)bRet;
  186. }