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.

209 lines
3.8 KiB

  1. /*++
  2. Copyright (c) 1994-1998, Microsoft Corporation All rights reserved.
  3. Module Name:
  4. keybd.c
  5. Abstract:
  6. This module contains the main routines for the Keyboard applet.
  7. Revision History:
  8. --*/
  9. //
  10. // Include Files.
  11. //
  12. #include "main.h"
  13. #include "rc.h"
  14. #include "applet.h"
  15. #include <regstr.h>
  16. #include <cplext.h>
  17. #include "util.h"
  18. #include <intlid.h>
  19. //
  20. // Constant Declarations.
  21. //
  22. #define MAX_PAGES 32 // limit on number of pages
  23. const HWPAGEINFO c_hpiKeybd = {
  24. // Keyboard device class
  25. { 0x4d36e96bL, 0xe325, 0x11ce, { 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18 } },
  26. // Keyboard troubleshooter command line
  27. IDS_KEYBD_TSHOOT,
  28. };
  29. //
  30. // Global Variables.
  31. //
  32. //
  33. // Location of prop sheet hooks in the registry.
  34. //
  35. static const TCHAR sc_szRegKeybd[] = REGSTR_PATH_CONTROLSFOLDER TEXT("\\Keyboard");
  36. //
  37. // Function Prototypes.
  38. //
  39. INT_PTR CALLBACK
  40. KeyboardSpdDlg(
  41. HWND hDlg,
  42. UINT message,
  43. WPARAM wParam,
  44. LPARAM lParam);
  45. ////////////////////////////////////////////////////////////////////////////
  46. //
  47. // _AddKeybdPropSheetPage
  48. //
  49. // Adds a property sheet page.
  50. //
  51. ////////////////////////////////////////////////////////////////////////////
  52. BOOL CALLBACK _AddKeybdPropSheetPage(
  53. HPROPSHEETPAGE hpage,
  54. LPARAM lParam)
  55. {
  56. PROPSHEETHEADER *ppsh = (PROPSHEETHEADER *)lParam;
  57. if (hpage && ppsh->nPages < MAX_PAGES)
  58. {
  59. ppsh->phpage[ppsh->nPages++] = hpage;
  60. return (TRUE);
  61. }
  62. return (FALSE);
  63. }
  64. ////////////////////////////////////////////////////////////////////////////
  65. //
  66. // KeybdApplet
  67. //
  68. ////////////////////////////////////////////////////////////////////////////
  69. int KeybdApplet(
  70. HINSTANCE instance,
  71. HWND parent,
  72. LPCTSTR cmdline)
  73. {
  74. HPROPSHEETPAGE rPages[MAX_PAGES];
  75. PROPSHEETPAGE psp;
  76. PROPSHEETHEADER psh;
  77. HPSXA hpsxa;
  78. int Result;
  79. //
  80. // Make the initial page.
  81. //
  82. psh.dwSize = sizeof(psh);
  83. psh.dwFlags = PSH_PROPTITLE;
  84. psh.hwndParent = parent;
  85. psh.hInstance = instance;
  86. psh.pszCaption = MAKEINTRESOURCE(IDS_KEYBD_TITLE);
  87. psh.nPages = 0;
  88. if (cmdline)
  89. {
  90. psh.nStartPage = lstrlen(cmdline) ? StrToLong(cmdline) : 0;
  91. }
  92. else
  93. {
  94. psh.nStartPage = 0;
  95. }
  96. psh.phpage = rPages;
  97. //
  98. // Load any installed extensions.
  99. //
  100. hpsxa = SHCreatePropSheetExtArray(HKEY_LOCAL_MACHINE, sc_szRegKeybd, 8);
  101. //
  102. // Add the Speed page.
  103. //
  104. psp.dwSize = sizeof(psp);
  105. psp.dwFlags = PSP_DEFAULT;
  106. psp.hInstance = instance;
  107. psp.pszTemplate = MAKEINTRESOURCE(DLG_KEYBD_SPEED);
  108. psp.pfnDlgProc = KeyboardSpdDlg;
  109. psp.lParam = 0;
  110. _AddKeybdPropSheetPage(CreatePropertySheetPage(&psp), (LPARAM)&psh);
  111. //
  112. // Add the Hardware page (not replaceable).
  113. //
  114. _AddKeybdPropSheetPage(CreateHardwarePage(&c_hpiKeybd), (LPARAM)&psh);
  115. //
  116. // Add any extra pages that the extensions want in there.
  117. //
  118. if (hpsxa)
  119. {
  120. UINT cutoff = psh.nPages;
  121. UINT added = SHAddFromPropSheetExtArray( hpsxa,
  122. _AddKeybdPropSheetPage,
  123. (LPARAM)&psh );
  124. if (psh.nStartPage >= cutoff)
  125. {
  126. psh.nStartPage += added;
  127. }
  128. }
  129. //
  130. // Invoke the Property Sheets.
  131. //
  132. switch (PropertySheet(&psh))
  133. {
  134. case ( ID_PSRESTARTWINDOWS ) :
  135. {
  136. Result = APPLET_RESTART;
  137. break;
  138. }
  139. case ( ID_PSREBOOTSYSTEM ) :
  140. {
  141. Result = APPLET_REBOOT;
  142. break;
  143. }
  144. default :
  145. {
  146. Result = 0;
  147. break;
  148. }
  149. }
  150. //
  151. // Free any loaded extensions.
  152. //
  153. if (hpsxa)
  154. {
  155. SHDestroyPropSheetExtArray(hpsxa);
  156. }
  157. return (Result);
  158. }