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.

245 lines
5.1 KiB

  1. /*++
  2. Copyright (c) 1994-1998, Microsoft Corporation All rights reserved.
  3. Module Name:
  4. mouse.c
  5. Abstract:
  6. This module contains the main routines for the Mouse 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. //
  19. // Constant Declarations.
  20. //
  21. #define MAX_PAGES 32
  22. const HWPAGEINFO c_hpiMouse = {
  23. // Mouse device class
  24. { 0x4d36e96fL, 0xe325, 0x11ce, { 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18 } },
  25. // Mouse troubleshooter command line
  26. IDS_MOUSE_TSHOOT,
  27. };
  28. //
  29. // Global Variables.
  30. //
  31. //
  32. // Location of prop sheet hooks in the registry.
  33. //
  34. static const TCHAR sc_szRegMouse[] = REGSTR_PATH_CONTROLSFOLDER TEXT("\\Mouse");
  35. //
  36. // Function Prototypes.
  37. //
  38. INT_PTR CALLBACK
  39. MouseButDlg(
  40. HWND hDlg,
  41. UINT message,
  42. WPARAM wParam,
  43. LPARAM lParam);
  44. INT_PTR CALLBACK
  45. MousePtrDlg(
  46. HWND hwnd,
  47. UINT msg,
  48. WPARAM wParam,
  49. LPARAM lParam);
  50. INT_PTR CALLBACK
  51. MouseMovDlg(
  52. HWND hDlg,
  53. UINT message,
  54. WPARAM wParam,
  55. LPARAM lParam);
  56. ////////////////////////////////////////////////////////////////////////////
  57. //
  58. // _AddMousePropSheetPage
  59. //
  60. // Adds a property sheet page.
  61. //
  62. ////////////////////////////////////////////////////////////////////////////
  63. BOOL CALLBACK _AddMousePropSheetPage(
  64. HPROPSHEETPAGE hpage,
  65. LPARAM lParam)
  66. {
  67. PROPSHEETHEADER *ppsh = (PROPSHEETHEADER *)lParam;
  68. if (hpage && (ppsh->nPages < MAX_PAGES))
  69. {
  70. ppsh->phpage[ppsh->nPages++] = hpage;
  71. return (TRUE);
  72. }
  73. return (FALSE);
  74. }
  75. ////////////////////////////////////////////////////////////////////////////
  76. //
  77. // MouseApplet
  78. //
  79. ////////////////////////////////////////////////////////////////////////////
  80. int MouseApplet(
  81. HINSTANCE instance,
  82. HWND parent,
  83. LPCTSTR cmdline)
  84. {
  85. HPROPSHEETPAGE rPages[MAX_PAGES];
  86. PROPSHEETPAGE psp;
  87. PROPSHEETHEADER psh;
  88. HPSXA hpsxa;
  89. int Result;
  90. //
  91. // Make the initial page.
  92. //
  93. psh.dwSize = sizeof(psh);
  94. psh.dwFlags = PSH_PROPTITLE;
  95. psh.hwndParent = parent;
  96. psh.hInstance = instance;
  97. psh.pszCaption = MAKEINTRESOURCE(IDS_MOUSE_TITLE);
  98. psh.nPages = 0;
  99. psh.nStartPage = 0;
  100. psh.phpage = rPages;
  101. //
  102. // Load any installed extensions.
  103. //
  104. hpsxa = SHCreatePropSheetExtArray(HKEY_LOCAL_MACHINE, sc_szRegMouse, 8);
  105. //
  106. // Add the Buttons page, giving the extensions a chance to replace it.
  107. //
  108. if (!hpsxa ||
  109. !SHReplaceFromPropSheetExtArray( hpsxa,
  110. CPLPAGE_MOUSE_BUTTONS,
  111. _AddMousePropSheetPage,
  112. (LPARAM)&psh ))
  113. {
  114. psp.dwSize = sizeof(psp);
  115. psp.dwFlags = PSP_DEFAULT;
  116. psp.hInstance = instance;
  117. psp.pszTemplate = MAKEINTRESOURCE(DLG_MOUSE_BUTTONS);
  118. psp.pfnDlgProc = MouseButDlg;
  119. psp.lParam = 0;
  120. _AddMousePropSheetPage(CreatePropertySheetPage(&psp), (LPARAM)&psh);
  121. }
  122. //
  123. // Add the Pointers page (not replaceable).
  124. //
  125. psp.dwSize = sizeof(psp);
  126. psp.dwFlags = PSP_DEFAULT;
  127. psp.hInstance = instance;
  128. psp.pszTemplate = MAKEINTRESOURCE(DLG_MOUSE_POINTER);
  129. psp.pfnDlgProc = MousePtrDlg;
  130. psp.lParam = 0;
  131. _AddMousePropSheetPage(CreatePropertySheetPage(&psp), (LPARAM)&psh);
  132. //
  133. // Add the Motion page, giving the extensions a chance to replace it.
  134. //
  135. if (!hpsxa ||
  136. !SHReplaceFromPropSheetExtArray( hpsxa,
  137. CPLPAGE_MOUSE_PTRMOTION,
  138. _AddMousePropSheetPage,
  139. (LPARAM)&psh ))
  140. {
  141. psp.dwSize = sizeof(psp);
  142. psp.dwFlags = PSP_DEFAULT;
  143. psp.hInstance = instance;
  144. psp.pszTemplate = MAKEINTRESOURCE(DLG_MOUSE_MOTION);
  145. psp.pfnDlgProc = MouseMovDlg;
  146. psp.lParam = 0;
  147. _AddMousePropSheetPage(CreatePropertySheetPage(&psp), (LPARAM)&psh);
  148. }
  149. _AddMousePropSheetPage(CreateHardwarePage(&c_hpiMouse), (LPARAM)&psh);
  150. //
  151. // Add any extra pages that the extensions want in there.
  152. //
  153. if (hpsxa)
  154. {
  155. UINT cutoff = psh.nPages;
  156. UINT added = SHAddFromPropSheetExtArray( hpsxa,
  157. _AddMousePropSheetPage,
  158. (LPARAM)&psh );
  159. if (psh.nStartPage >= cutoff)
  160. {
  161. psh.nStartPage += added;
  162. }
  163. }
  164. //
  165. // Invoke the Property Sheets.
  166. //
  167. switch (PropertySheet(&psh))
  168. {
  169. case ( ID_PSRESTARTWINDOWS ) :
  170. {
  171. Result = APPLET_RESTART;
  172. break;
  173. }
  174. case ( ID_PSREBOOTSYSTEM ) :
  175. {
  176. Result = APPLET_REBOOT;
  177. break;
  178. }
  179. default :
  180. {
  181. Result = 0;
  182. break;
  183. }
  184. }
  185. //
  186. // Free any loaded extensions.
  187. //
  188. if (hpsxa)
  189. {
  190. SHDestroyPropSheetExtArray(hpsxa);
  191. }
  192. return (Result);
  193. }