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.

251 lines
9.5 KiB

  1. // ********************************************************************
  2. // Main.c
  3. // Main init entry into the Human Accessibilities Control panel applet
  4. // ********************************************************************
  5. #include <assert.h>
  6. #pragma comment(lib, "comctl32.lib")
  7. #include "Access.h"
  8. HINSTANCE g_hinst = NULL;
  9. BOOL OpenAccessPropertySheet (HWND, int);
  10. // Define our help data structure
  11. const DWORD g_aIds[] = {
  12. #if 1
  13. IDC_NO_HELP_1, NO_HELP,
  14. IDC_STK_ENABLE, IDH_STICKYKEYS_ENABLE,
  15. IDC_SK_TEXT, IDH_STICKYKEYS_ENABLE,
  16. IDC_STK_SETTINGS, IDH_STICKYKEYS_SETTINGS,
  17. IDC_FK_ENABLE, IDH_FILTERKEYS_ENABLE,
  18. IDC_FK_TEXT, IDH_FILTERKEYS_ENABLE,
  19. IDC_FK_SETTINGS, IDH_FILTERKEYS_SETTINGS,
  20. IDC_TK_ENABLE, IDH_TOGGLEKEYS_ENABLE,
  21. IDC_TK_TEXT, IDH_TOGGLEKEYS_ENABLE,
  22. IDC_TK_SETTINGS, IDH_TOGGLEKEYS_SETTINGS,
  23. IDC_STK_HOTKEY, IDH_STICKYKEYS_HOTKEY,
  24. IDC_STK_TEXT, IDH_STICKYKEYS_HOTKEY,
  25. IDC_STK_LOCK, IDH_STICKYKEYS_LOCK,
  26. IDC_STK_2KEYS, IDH_STICKYKEYS_2KEYS,
  27. IDC_STK_SOUNDMOD, IDH_STICKYKEYS_SOUND,
  28. IDC_STK_STATUS, IDH_STICKYKEYS_STATUS,
  29. IDC_FK_HOTKEY, IDH_FILTERKEYS_HOTKEY,
  30. IDC_FK_TEXT1, IDH_FILTERKEYS_HOTKEY,
  31. IDC_FK_REPEAT, IDH_FILTERKEYS_REPEATKEYS,
  32. IDC_BK_SETTINGS, IDH_FILTERKEYS_BKSETTINGS,
  33. IDC_FK_BOUNCE, IDH_FILTERKEYS_BOUNCEKEYS,
  34. IDC_RK_SETTINGS, IDH_FILTERKEYS_SETTINGS_REPEAT,
  35. IDC_FK_TESTBOX, IDH_FILTERKEYS_TESTBOX,
  36. IDC_FK_SOUND, IDH_FILTERKEYS_BEEPONKEYPRESS,
  37. IDC_FK_STATUS, IDH_FILTERKEYS_SPAWNSTATUSAPP,
  38. IDC_RK_NOREPEAT, IDH_FILTERKEYS_NO_REPEAT,
  39. IDC_RK_REPEAT, IDH_FILTERKEYS_SLOW,
  40. IDC_RK_DELAYRATE_LBL, IDH_REPEAT_DELAY,
  41. IDC_CMB_RK_DELAYRATE, IDH_FILTERKEYS_DELAY,
  42. IDC_RK_REPEATRATE_LBL, IDH_REPEAT_RATE,
  43. IDC_CMB_RK_REPEATRATE, IDH_FILTERKEYS_RATE,
  44. IDC_RK_ACCEPTRATE_LBL, IDH_VALID_KEY_TIME,
  45. IDC_CMB_RK_ACCEPTRATE, IDH_FILTERKEYS_KEYSPEED,
  46. IDC_RK_TESTBOX, IDH_FILTERKEYS_TEST1,
  47. IDC_BK_TIME_LBL1, IDH_FILTERKEYS_IGNORE_REPEAT,
  48. IDC_BK_TIME_LBL2, IDH_KEY_PRESS_TIME,
  49. IDC_CMB_BK_BOUNCERATE, IDH_FILTERKEYS_IGNORE_REPEAT,
  50. IDC_BK_TESTBOX, IDH_FILTERKEYS_TEST2,
  51. IDC_TK_HOTKEY, IDH_TOGGLEKEYS_HOTKEY,
  52. IDC_TK_TEXT1, IDH_TOGGLEKEYS_HOTKEY,
  53. IDC_SS_ENABLE_SOUND, IDH_SOUNDSENTRY_ENABLE,
  54. IDC_SS_TEXT, IDH_SOUNDSENTRY_ENABLE,
  55. IDC_SS_ENABLE_SHOW, IDH_SHOWSOUNDS_ENABLE,
  56. IDC_SS_TEXT1, IDH_SHOWSOUNDS_ENABLE,
  57. IDC_SS_WINDOWED, IDH_SOUNDSENTRY_WINDOWED,
  58. IDC_SS_CHOOSE, IDH_SOUNDSENTRY_WINDOWED,
  59. IDC_HC_ENABLE, IDH_HIGHCONTRAST_ENABLE,
  60. IDC_HC_TEXT, IDH_HIGHCONTRAST_ENABLE,
  61. IDC_HC_SETTINGS, IDH_HIGHCONTRAST_SETTINGS,
  62. IDC_HC_HOTKEY, IDH_HIGHCONTRAST_HOTKEY,
  63. IDC_HC_TEXT1, IDH_HIGHCONTRAST_HOTKEY,
  64. IDC_KCURSOR_RATE, IDH_KCURSOR_RATE,
  65. IDC_KCUR_TEXT_RATE, IDH_KCURSOR_RATE,
  66. IDC_KCUR_TEXT_NONE, IDH_KCURSOR_RATE,
  67. IDC_KCUR_TEXT_FAST, IDH_KCURSOR_RATE,
  68. IDC_KCURSOR_WIDTH, IDH_KCURSOR_WIDTH,
  69. IDC_KCUR_TEXT_WIDTH, IDH_KCURSOR_WIDTH,
  70. IDC_KCUR_TEXT_NARR, IDH_KCURSOR_WIDTH,
  71. IDC_KCUR_TEXT_WIDE, IDH_KCURSOR_WIDTH,
  72. IDC_KCURSOR_OPTS, IDH_KCURSOR_OPTS,
  73. IDC_HC_DEFAULTSCHEME, IDH_HIGHCONTRAST_DEFAULTSCHEME,
  74. IDC_HC_CURSCHEME, IDH_HIGHCONTRAST_DEFAULTSCHEME,
  75. IDC_MK_ENABLE, IDH_MOUSEKEYS_ENABLE,
  76. IDC_MK_TEXT, IDH_MOUSEKEYS_ENABLE,
  77. IDC_MK_SETTINGS, IDH_MOUSEKEYS_SETTINGS,
  78. IDC_MK_HOTKEY, IDH_MOUSEKEYS_HOTKEY,
  79. IDC_MK_TEXT1, IDH_MOUSEKEYS_HOTKEY,
  80. IDC_MK_TOPSPEED, IDH_MOUSEKEYS_MAXSPEED,
  81. IDC_MK_SPEED, IDH_MOUSEKEYS_MAXSPEED,
  82. IDC_MK_SPEED_LOW, IDH_MOUSEKEYS_MAXSPEED,
  83. IDC_MK_SPEED_HIGH, IDH_MOUSEKEYS_MAXSPEED,
  84. IDC_MK_ACCEL, IDH_MOUSEKEYS_ACCELERATION,
  85. IDC_MK_ACCELER, IDH_MOUSEKEYS_ACCELERATION,
  86. IDC_MK_ACCELER_SLOW, IDH_MOUSEKEYS_ACCELERATION,
  87. IDC_MK_ACCELER_FAST, IDH_MOUSEKEYS_ACCELERATION,
  88. IDC_MK_USEMODKEYS, IDH_MOUSEKEYS_USEMODIFIERKEYS,
  89. IDC_MK_NLOFF, IDH_MOUSEKEYS_NUMLOCKMODE,
  90. IDC_MK_NLON, IDH_MOUSEKEYS_NUMLOCKMODE,
  91. IDC_MK_TEXT2, IDH_MOUSEKEYS_NUMLOCKMODE,
  92. IDC_MK_STATUS, IDH_MOUSEKEYS_SPAWNSTATUSAPP,
  93. // IDC_SAVE_SETTINGS, IDH_ACCESS_SAVESETTINGS,
  94. IDC_TO_ENABLE, IDH_ACCESS_TIMEOUT,
  95. IDC_TO_TIMEOUTVAL, IDH_ACCESS_TIMEOUT,
  96. IDC_WARNING_SOUND, IDH_ACCESS_CONFIRMHOTKEY,
  97. IDC_SOUND_ONOFF, IDH_ACCESS_SOUNDONHOTKEY,
  98. IDC_SK_ENABLE, IDH_SERIALKEYS_ENABLE,
  99. IDC_SERKEY_TEXT, IDH_SERIALKEYS_ENABLE,
  100. IDC_SK_SETTINGS, IDH_SERIALKEYS_SETTINGS,
  101. IDC_SK_PORT, IDH_SERIALKEYS_SERIAL,
  102. IDC_SK_PORTEXT, IDH_SERIALKEYS_SERIAL,
  103. IDC_SK_BAUD, IDH_SERIALKEYS_BAUD,
  104. IDC_SK_BAUD_TEXT, IDH_SERIALKEYS_BAUD,
  105. IDC_CHECK1, IDH_SHOW_KEYBOARD_HELP,
  106. IDC_ADMIN_LOGON, 2010,
  107. IDC_ADMIN_DEFAULT, 2011,
  108. #endif
  109. 0, 0
  110. } ;
  111. // ************************************************************************
  112. // Our entry point...
  113. // ************************************************************************
  114. BOOL WINAPI DllMain (HANDLE hinstDll, DWORD dwReason, LPVOID lpReserved) {
  115. switch (dwReason) {
  116. case DLL_PROCESS_ATTACH: g_hinst = hinstDll; break;
  117. case DLL_PROCESS_DETACH: break;
  118. case DLL_THREAD_DETACH: break;
  119. case DLL_THREAD_ATTACH: break;
  120. }
  121. return(TRUE);
  122. }
  123. #define SPI_OFF(T, M) \
  124. { \
  125. T s; \
  126. s.cbSize = sizeof(T); \
  127. if (!SystemParametersInfo(SPI_GET##T, s.cbSize, &s, 0)) \
  128. return E_FAIL; \
  129. \
  130. if (s.dwFlags & M) \
  131. { \
  132. s.dwFlags &= ~M; \
  133. if (!SystemParametersInfo(SPI_SET##T, s.cbSize, &s, 0)) \
  134. return E_FAIL; \
  135. } \
  136. }
  137. HRESULT WINAPI DllUnregisterServer(void)
  138. {
  139. SPI_OFF(FILTERKEYS, FKF_HOTKEYACTIVE)
  140. SPI_OFF(HIGHCONTRAST, HCF_HOTKEYACTIVE)
  141. SPI_OFF(MOUSEKEYS, MKF_HOTKEYACTIVE)
  142. SPI_OFF(STICKYKEYS, SKF_HOTKEYACTIVE)
  143. SPI_OFF(TOGGLEKEYS, TKF_HOTKEYACTIVE)
  144. return S_OK;
  145. }
  146. HRESULT WINAPI DllRegisterServer(void)
  147. {
  148. return S_OK;
  149. }
  150. // This is the RUNDLLPROC prototype
  151. // I got it from Win95 source code \WIN\CORE\SHELL\CPLS\MSPRINT\MSPRINT\MSPRINT.C
  152. // It should be in some Windows header file but I could not find it!
  153. typedef VOID (WINAPI *RUNDLLPROC)(HWND, HINSTANCE, LPTSTR, int);
  154. VOID WINAPI DebugMain (HWND hwnd, HINSTANCE hinstExe, LPSTR pszCmdLine, int nCmdShow) {
  155. OpenAccessPropertySheet(hwnd, 0);
  156. }
  157. /////////////////////////////////////////////////////////////////////////////
  158. // CplApplet:
  159. // The main applet information manager.
  160. /////////////////////////////////////////////////////////////////////////////
  161. LONG WINAPI CPlApplet (HWND hwnd, UINT uMsg, LPARAM lParam1, LPARAM lParam2) {
  162. LONG lRetVal = TRUE;
  163. switch (uMsg) {
  164. case CPL_INIT:
  165. // If initialization is successful, return TRUE; else FALSE
  166. break;
  167. case CPL_GETCOUNT:
  168. // There is only 1 applet in this DLL
  169. lRetVal = 1;
  170. break;
  171. case CPL_INQUIRE:
  172. Assert(lParam1 == 0); // Applet number in the DLL
  173. #define lpOldCPlInfo ((LPCPLINFO) lParam2)
  174. lpOldCPlInfo->idIcon = IDI_ACCESS;
  175. lpOldCPlInfo->idName = IDS_ACCESS;
  176. lpOldCPlInfo->idInfo = IDS_ACCESSINFO;
  177. lpOldCPlInfo->lData = 0;
  178. break;
  179. case CPL_NEWINQUIRE:
  180. Assert(lParam1 == 0); // Applet number in the DLL
  181. #define lpCPlInfo ((LPNEWCPLINFO) lParam2)
  182. lpCPlInfo->dwSize = sizeof(NEWCPLINFO);
  183. lpCPlInfo->dwFlags = 0;
  184. lpCPlInfo->dwHelpContext = 0;
  185. lpCPlInfo->lData = 0;
  186. lpCPlInfo->hIcon = LoadIcon(g_hinst, MAKEINTRESOURCE(IDI_ACCESS));
  187. LoadString(g_hinst, IDS_ACCESS, lpCPlInfo->szName, ARRAY_SIZE(lpCPlInfo->szName));
  188. LoadString(g_hinst, IDS_ACCESSINFO, lpCPlInfo->szInfo, ARRAY_SIZE(lpCPlInfo->szInfo));
  189. lpCPlInfo->szHelpFile[0] = 0;
  190. #undef lpCPlInfo
  191. lRetVal = 1; // Tell the system that we responded to this message
  192. // Returning 1 causes the system to NOT send the CPL_INQUIRE message
  193. break;
  194. case CPL_STARTWPARMS:
  195. Assert(lParam1 == 0); // Applet number in the DLL
  196. OpenAccessPropertySheet(hwnd, (int) ((* (PBYTE) lParam2) - 0x31));
  197. lRetVal = TRUE;
  198. break;
  199. case CPL_DBLCLK:
  200. Assert(lParam1 == 0); // Applet number in the DLL
  201. OpenAccessPropertySheet(hwnd, 0);
  202. lRetVal = 0; // Success
  203. break;
  204. case CPL_EXIT:
  205. // Free up any allocations of resources made.
  206. // If de-initialization is successful, return TRUE; else FALSE
  207. break;
  208. }
  209. return(lRetVal);
  210. }
  211. // ***********************************************************************
  212. // FeatureUnavailible
  213. // Show the "I can't do that" dialog box for features that are currently
  214. // disabled.
  215. // ***********************************************************************
  216. void FeatureUnavailible (HWND hwnd) {
  217. TCHAR szTitle[100];
  218. TCHAR szText[256];
  219. if (LoadString(g_hinst, IDS_UNAVAIL_TITLE, szTitle, ARRAY_SIZE(szTitle)))
  220. if (LoadString(g_hinst, IDS_UNAVAIL_TEXT, szText, ARRAY_SIZE(szText)))
  221. MessageBox(hwnd, szText, szTitle, MB_OK);
  222. }
  223. ///////////////////////////////// End of File /////////////////////////////////