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.

233 lines
7.3 KiB

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