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.

519 lines
14 KiB

  1. //Copyright (c) 1997-2000 Microsoft Corporation
  2. #ifndef _INC_PGEXTRAS_H
  3. #define _INC_PGEXTRAS_H
  4. #include "pgbase.h"
  5. #include "Select.h"
  6. class CYesNoPg : public WizardPage
  7. {
  8. public:
  9. CYesNoPg(LPPROPSHEETPAGE ppsp, int nIdTitle, int nIdSubTitle, int nPageId)
  10. : WizardPage(ppsp, nIdTitle, nIdSubTitle)
  11. {
  12. m_dwPageId = nPageId;
  13. ppsp->pszTemplate = MAKEINTRESOURCE(m_dwPageId);
  14. }
  15. protected:
  16. virtual BOOL IsOptionSet() = 0;
  17. virtual void SetOptions(BOOL bOn) = 0;
  18. virtual int GetSettingsPage() {return 0;} // Default is no next page
  19. LRESULT OnInitDialog(HWND hwnd, WPARAM wParam, LPARAM lParam)
  20. {
  21. // Make sure the controls exist
  22. _ASSERTE(GetDlgItem(m_hwnd, IDC_RADIOYES));
  23. _ASSERTE(GetDlgItem(m_hwnd, IDC_RADIONO));
  24. // Set Yes/No buttons
  25. Button_SetCheck(GetDlgItem(m_hwnd, IDC_RADIOYES), IsOptionSet());
  26. Button_SetCheck(GetDlgItem(m_hwnd, IDC_RADIONO), !IsOptionSet());
  27. return 1;
  28. }
  29. LRESULT OnCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
  30. {
  31. LRESULT lResult = 1;
  32. SetOptions(Button_GetCheck(GetDlgItem(m_hwnd, IDC_RADIOYES)));
  33. g_Options.ApplyPreview();
  34. return lResult;
  35. }
  36. LRESULT OnPSN_WizNext(HWND hwnd, INT idCtl, LPPSHNOTIFY pnmh)
  37. {
  38. DWORD dwTemp = GetSettingsPage();
  39. if(dwTemp)
  40. {
  41. if(Button_GetCheck(GetDlgItem(m_hwnd, IDC_RADIOYES)))
  42. sm_WizPageOrder.AddPages(m_dwPageId, &dwTemp, 1);
  43. else
  44. sm_WizPageOrder.RemovePages(&dwTemp, 1);
  45. }
  46. return WizardPage::OnPSN_WizNext(hwnd, idCtl, pnmh);
  47. }
  48. };
  49. class CSoundSentryPg : public CYesNoPg
  50. {
  51. public:
  52. CSoundSentryPg(LPPROPSHEETPAGE ppsp)
  53. : CYesNoPg(ppsp, IDS_SNDWIZSENTRYTITLE, IDS_SNDWIZSENTRYSUBTITLE, IDD_SNDWIZSENTRYSHOWSOUNDS) {}
  54. protected:
  55. BOOL IsOptionSet()
  56. {
  57. return (g_Options.m_schemePreview.m_SOUNDSENTRY.dwFlags & SSF_SOUNDSENTRYON);
  58. }
  59. void SetOptions(BOOL bOn)
  60. {
  61. if(bOn)
  62. {
  63. g_Options.m_schemePreview.m_SOUNDSENTRY.dwFlags |= SSF_SOUNDSENTRYON;
  64. g_Options.m_schemePreview.m_SOUNDSENTRY.dwFlags &= SSF_VALID;
  65. // Hard code to flash 'Window' if we are setting this option
  66. g_Options.m_schemePreview.m_SOUNDSENTRY.iWindowsEffect = SSWF_WINDOW;
  67. // For NT: The other options are not supported. a-anilk
  68. g_Options.m_schemePreview.m_SOUNDSENTRY.iFSTextEffect = 0;
  69. g_Options.m_schemePreview.m_SOUNDSENTRY.iFSGrafEffect = 0;
  70. }
  71. else
  72. g_Options.m_schemePreview.m_SOUNDSENTRY.dwFlags &= ~SSF_SOUNDSENTRYON;
  73. }
  74. };
  75. class CShowSoundsPg : public CYesNoPg
  76. {
  77. public:
  78. CShowSoundsPg(LPPROPSHEETPAGE ppsp)
  79. : CYesNoPg(ppsp, IDS_SNDWIZSHOWSOUNDSTITLE, IDS_SNDWIZSHOWSOUNDSSUBTITLE, IDD_SNDWIZSENTRYSHOWSOUNDS2) {}
  80. protected:
  81. BOOL IsOptionSet()
  82. {
  83. return (g_Options.m_schemePreview.m_bShowSounds);
  84. }
  85. void SetOptions(BOOL bOn)
  86. {
  87. g_Options.m_schemePreview.m_bShowSounds = bOn;
  88. }
  89. };
  90. class CFilterKeysPg : public CYesNoPg
  91. {
  92. public:
  93. CFilterKeysPg(LPPROPSHEETPAGE ppsp)
  94. : CYesNoPg(ppsp, IDS_WIZFILTERKEYSTITLE, IDS_WIZFILTERKEYSSUBTITLE, IDD_KBDWIZFILTERKEYS1) {}
  95. protected:
  96. BOOL IsOptionSet()
  97. {
  98. // Return TRUE if filterkeys is ON
  99. return (g_Options.m_schemePreview.m_FILTERKEYS.dwFlags & FKF_FILTERKEYSON);
  100. }
  101. void SetOptions(BOOL bOn)
  102. {
  103. if(bOn)
  104. {
  105. g_Options.m_schemePreview.m_FILTERKEYS.dwFlags |= FKF_FILTERKEYSON;
  106. // this code only sets iBounceMSec and doesn't let users set the
  107. // other filter key options so init the other values to zero
  108. g_Options.m_schemePreview.m_FILTERKEYS.iWaitMSec = 0;
  109. g_Options.m_schemePreview.m_FILTERKEYS.iDelayMSec = 0;
  110. g_Options.m_schemePreview.m_FILTERKEYS.iRepeatMSec = 0;
  111. }
  112. else
  113. {
  114. g_Options.m_schemePreview.m_FILTERKEYS.dwFlags &= ~FKF_FILTERKEYSON;
  115. }
  116. }
  117. int GetSettingsPage() {return IDD_KBDWIZFILTERKEYS2;}
  118. };
  119. /***************************************/
  120. //
  121. // Times are in milliseconds
  122. //
  123. #define BOUNCESIZE 5
  124. UINT BounceTable[BOUNCESIZE] = {
  125. { 500 },
  126. { 700 },
  127. { 1000 },
  128. { 1500 },
  129. { 2000 }
  130. };
  131. class CFilterKeysSettingsPg : public WizardPage
  132. {
  133. public:
  134. CFilterKeysSettingsPg(LPPROPSHEETPAGE ppsp)
  135. : WizardPage(ppsp, IDS_WIZFILTERKEYSETTING, IDS_WIZFILTERKEYSSUBTITLE)
  136. {
  137. m_dwPageId = IDD_KBDWIZFILTERKEYS2;
  138. ppsp->pszTemplate = MAKEINTRESOURCE(m_dwPageId);
  139. }
  140. protected:
  141. void UpdateTime()
  142. {
  143. INT_PTR nBounceRate = SendDlgItemMessage(m_hwnd,IDC_BK_BOUNCERATE, TBM_GETPOS, 0,0);
  144. if(nBounceRate < 1 || nBounceRate > BOUNCESIZE)
  145. nBounceRate = 1;
  146. // Look up in table
  147. nBounceRate = BounceTable[nBounceRate - 1];
  148. TCHAR buf[10], buf2[20];
  149. wsprintf(buf,__TEXT("%d.%d"),nBounceRate/1000, (nBounceRate%1000)/100);
  150. GetNumberFormat(LOCALE_USER_DEFAULT, 0, buf, NULL, buf2, 20);
  151. SetDlgItemText(m_hwnd, IDC_BK_TIME, buf2);
  152. }
  153. LRESULT OnInitDialog(HWND hwnd, WPARAM wParam, LPARAM lParam)
  154. {
  155. _ASSERTE(g_Options.m_schemePreview.m_FILTERKEYS.iBounceMSec);
  156. _ASSERTE(GetDlgItem(m_hwnd, IDC_RADIOBEEPYES));
  157. _ASSERTE(GetDlgItem(m_hwnd, IDC_RADIOBEEPNO));
  158. Button_SetCheck(GetDlgItem(m_hwnd, IDC_RADIOBEEPYES), (g_Options.m_schemePreview.m_FILTERKEYS.dwFlags & FKF_CLICKON));
  159. Button_SetCheck(GetDlgItem(m_hwnd, IDC_RADIOBEEPNO), !(g_Options.m_schemePreview.m_FILTERKEYS.dwFlags & FKF_CLICKON));
  160. // Set slider for bounce rate
  161. SendDlgItemMessage(m_hwnd,IDC_BK_BOUNCERATE, TBM_SETRANGE,
  162. TRUE,MAKELONG(1,BOUNCESIZE));
  163. // Figure out initial settings
  164. // Make sure initial slider settings is not SMALLER than current setting
  165. int nIndex = 0;
  166. for(int i=BOUNCESIZE - 1;i>=0;i--)
  167. {
  168. if(BounceTable[i] >= g_Options.m_schemePreview.m_FILTERKEYS.iBounceMSec)
  169. nIndex = i;
  170. else
  171. break;
  172. }
  173. SendDlgItemMessage(m_hwnd,IDC_BK_BOUNCERATE, TBM_SETPOS, TRUE, nIndex+1);
  174. UpdateTime();
  175. return 1;
  176. }
  177. LRESULT HandleMsg(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  178. {
  179. switch(uMsg)
  180. {
  181. case WM_HSCROLL:
  182. {
  183. UpdateTime();
  184. if(Button_GetCheck(GetDlgItem(m_hwnd, IDC_RADIOBEEPYES)))
  185. g_Options.m_schemePreview.m_FILTERKEYS.dwFlags |= FKF_CLICKON;
  186. else
  187. g_Options.m_schemePreview.m_FILTERKEYS.dwFlags &= ~FKF_CLICKON;
  188. // Bounce Keys
  189. INT_PTR nIndex = SendDlgItemMessage(m_hwnd, IDC_BK_BOUNCERATE, TBM_GETPOS, 0, 0);
  190. // this code only sets iBounceMSec and doesn't let users set the
  191. // other filter key options so init the other values to zero
  192. g_Options.m_schemePreview.m_FILTERKEYS.iWaitMSec = 0;
  193. g_Options.m_schemePreview.m_FILTERKEYS.iDelayMSec = 0;
  194. g_Options.m_schemePreview.m_FILTERKEYS.iRepeatMSec = 0;
  195. g_Options.m_schemePreview.m_FILTERKEYS.iBounceMSec = BounceTable[nIndex - 1];
  196. g_Options.ApplyPreview();
  197. }
  198. break;
  199. default:
  200. break;
  201. }
  202. return 0;
  203. }
  204. // Handle Next> and make sure you transfer all settings as the user may not
  205. // always change bounce repeat rate : a-anilk
  206. LRESULT OnCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
  207. {
  208. LRESULT lResult = 1;
  209. WORD wNotifyCode = HIWORD(wParam);
  210. WORD wCtlID = LOWORD(wParam);
  211. HWND hwndCtl = (HWND)lParam;
  212. switch(wCtlID)
  213. {
  214. case IDC_RADIOBEEPYES:
  215. case IDC_RADIOBEEPNO:
  216. if(Button_GetCheck(GetDlgItem(m_hwnd, IDC_RADIOBEEPYES)))
  217. g_Options.m_schemePreview.m_FILTERKEYS.dwFlags |= FKF_CLICKON;
  218. else
  219. g_Options.m_schemePreview.m_FILTERKEYS.dwFlags &= ~FKF_CLICKON;
  220. g_Options.ApplyPreview();
  221. lResult = 0;
  222. break;
  223. default:
  224. break;
  225. }
  226. return lResult;
  227. }
  228. };
  229. ////////////////////////////////////////////////////////////////////
  230. // Mouse Keys
  231. class CMouseKeysPg : public CYesNoPg
  232. {
  233. public:
  234. CMouseKeysPg(LPPROPSHEETPAGE ppsp)
  235. : CYesNoPg(ppsp, IDS_MSEWIZMOUSEKEYSTITLE, IDS_MSEWIZMOUSEKEYSSUBTITLE, IDD_MSEWIZMOUSEKEYS) {}
  236. protected:
  237. BOOL IsOptionSet()
  238. {
  239. return (g_Options.m_schemePreview.m_MOUSEKEYS.dwFlags & MKF_MOUSEKEYSON);
  240. }
  241. void SetOptions(BOOL bOn)
  242. {
  243. if(bOn)
  244. g_Options.m_schemePreview.m_MOUSEKEYS.dwFlags |= MKF_MOUSEKEYSON;
  245. else
  246. g_Options.m_schemePreview.m_MOUSEKEYS.dwFlags &= ~MKF_MOUSEKEYSON;
  247. }
  248. int GetSettingsPage() {return IDD_MSEWIZMOUSEKEYS1;}
  249. };
  250. static UINT g_nSpeedTable[] = { 10, 20, 30, 40, 60, 80, 120, 180, 360 };
  251. static UINT g_nAccelTable[] = { 5000, 4500, 4000, 3500, 3000, 2500, 2000, 1500, 1000 };
  252. class CMouseKeysSettingsPg : public WizardPage
  253. {
  254. public:
  255. CMouseKeysSettingsPg(LPPROPSHEETPAGE ppsp)
  256. : WizardPage(ppsp, IDS_MSEWIZMOUSEKEYSETTING, IDS_MSEWIZMOUSEKEYSSUBTITLE)
  257. {
  258. m_dwPageId = IDD_MSEWIZMOUSEKEYS1;
  259. ppsp->pszTemplate = MAKEINTRESOURCE(m_dwPageId);
  260. }
  261. protected:
  262. LRESULT OnInitDialog(HWND hwnd, WPARAM wParam, LPARAM lParam)
  263. {
  264. // ALWAYS use modifiers
  265. // Button_SetCheck(GetDlgItem(m_hwnd, IDC_MK_USEMODKEYS), g_Options.m_schemePreview.m_MOUSEKEYS.dwFlags & MKF_MODIFIERS);
  266. if(g_Options.m_schemePreview.m_MOUSEKEYS.dwFlags & MKF_REPLACENUMBERS)
  267. Button_SetCheck(GetDlgItem(m_hwnd, IDC_MK_NLON), TRUE);
  268. else
  269. Button_SetCheck(GetDlgItem(m_hwnd, IDC_MK_NLOFF), TRUE);
  270. SendDlgItemMessage(m_hwnd,IDC_MK_TOPSPEED, TBM_SETRANGE, TRUE,MAKELONG(0,8));
  271. SendDlgItemMessage(m_hwnd,IDC_MK_ACCEL, TBM_SETRANGE, TRUE,MAKELONG(0,8));
  272. int nIndex = 0;
  273. for(int i=8;i>=0;i--)
  274. {
  275. if(g_nSpeedTable[i] >= g_Options.m_schemePreview.m_MOUSEKEYS.iMaxSpeed)
  276. nIndex = i;
  277. else
  278. break;
  279. }
  280. SendDlgItemMessage(m_hwnd,IDC_MK_TOPSPEED, TBM_SETPOS, TRUE, nIndex);
  281. for(i=8;i>=0;i--)
  282. {
  283. if(g_nAccelTable[i] <= g_Options.m_schemePreview.m_MOUSEKEYS.iTimeToMaxSpeed)
  284. nIndex = i;
  285. else
  286. break;
  287. }
  288. SendDlgItemMessage(m_hwnd,IDC_MK_ACCEL, TBM_SETPOS, TRUE, nIndex);
  289. return 1;
  290. }
  291. void GetSettingsFromControls()
  292. {
  293. INT_PTR nIndex;
  294. g_Options.m_schemePreview.m_MOUSEKEYS.dwFlags |= MKF_MOUSEKEYSON;
  295. if(TRUE/*Button_GetCheck(GetDlgItem(m_hwnd, IDC_MK_USEMODKEYS))*/) // NOTE: ALWAYS use modifiers
  296. g_Options.m_schemePreview.m_MOUSEKEYS.dwFlags |= MKF_MODIFIERS;
  297. else
  298. g_Options.m_schemePreview.m_MOUSEKEYS.dwFlags &= ~MKF_MODIFIERS;
  299. if(Button_GetCheck(GetDlgItem(m_hwnd, IDC_MK_NLON)))
  300. g_Options.m_schemePreview.m_MOUSEKEYS.dwFlags |= MKF_REPLACENUMBERS;
  301. else
  302. g_Options.m_schemePreview.m_MOUSEKEYS.dwFlags &= ~MKF_REPLACENUMBERS;
  303. nIndex = SendDlgItemMessage(m_hwnd, IDC_MK_TOPSPEED, TBM_GETPOS, 0, 0);
  304. g_Options.m_schemePreview.m_MOUSEKEYS.iMaxSpeed = g_nSpeedTable[nIndex];
  305. nIndex = SendDlgItemMessage(m_hwnd, IDC_MK_ACCEL, TBM_GETPOS, 0, 0);
  306. g_Options.m_schemePreview.m_MOUSEKEYS.iTimeToMaxSpeed = g_nAccelTable[nIndex];
  307. #pragma message("Handle THis!")
  308. // 3/15/95 -
  309. // Always init the control speed to 1/8 of the screen width/
  310. // g_mk.iCtrlSpeed = GetSystemMetrics(SM_CXSCREEN) / 16;
  311. g_Options.ApplyPreview();
  312. }
  313. LRESULT HandleMsg(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  314. {
  315. switch(uMsg)
  316. {
  317. case WM_HSCROLL:
  318. GetSettingsFromControls();
  319. break;
  320. default:
  321. break;
  322. }
  323. return 0;
  324. }
  325. LRESULT OnCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
  326. {
  327. LRESULT lResult = 1;
  328. WORD wNotifyCode = HIWORD(wParam);
  329. WORD wCtlID = LOWORD(wParam);
  330. HWND hwndCtl = (HWND)lParam;
  331. switch(wCtlID)
  332. {
  333. case IDC_MK_NLON:
  334. case IDC_MK_NLOFF:
  335. GetSettingsFromControls();
  336. lResult = 0;
  337. break;
  338. default:
  339. break;
  340. }
  341. return lResult;
  342. }
  343. };
  344. //
  345. ////////////////////////////////////////////////////////////////////
  346. class CStickyKeysPg : public CYesNoPg
  347. {
  348. public:
  349. CStickyKeysPg(LPPROPSHEETPAGE ppsp)
  350. : CYesNoPg(ppsp, IDS_WIZSTICKYKEYSTITLE, IDS_WIZSTICKYKEYSSUBTITLE, IDD_KBDWIZSTICKYKEYS) {}
  351. protected:
  352. BOOL IsOptionSet()
  353. {
  354. return g_Options.m_schemePreview.m_STICKYKEYS.dwFlags & SKF_STICKYKEYSON;
  355. }
  356. void SetOptions(BOOL bOn)
  357. {
  358. if(bOn)
  359. {
  360. g_Options.m_schemePreview.m_STICKYKEYS.dwFlags |= SKF_STICKYKEYSON;
  361. // Turn selected flags on
  362. g_Options.m_schemePreview.m_STICKYKEYS.dwFlags |= SKF_TRISTATE;
  363. g_Options.m_schemePreview.m_STICKYKEYS.dwFlags |= SKF_TWOKEYSOFF;
  364. g_Options.m_schemePreview.m_STICKYKEYS.dwFlags |= SKF_AUDIBLEFEEDBACK;
  365. }
  366. else
  367. g_Options.m_schemePreview.m_STICKYKEYS.dwFlags &= ~SKF_STICKYKEYSON;
  368. }
  369. };
  370. class CToggleKeysPg : public CYesNoPg
  371. {
  372. public:
  373. CToggleKeysPg(LPPROPSHEETPAGE ppsp)
  374. : CYesNoPg(ppsp, IDS_WIZTOGGLEKEYSTITLE, IDS_WIZTOGGLEKEYSSUBTITLE, IDD_KBDWIZTOGGLEKEYS) {}
  375. protected:
  376. BOOL IsOptionSet()
  377. {
  378. return g_Options.m_schemePreview.m_TOGGLEKEYS.dwFlags & TKF_TOGGLEKEYSON;
  379. }
  380. void SetOptions(BOOL bOn)
  381. {
  382. if(bOn)
  383. g_Options.m_schemePreview.m_TOGGLEKEYS.dwFlags |= TKF_TOGGLEKEYSON;
  384. else
  385. g_Options.m_schemePreview.m_TOGGLEKEYS.dwFlags &= ~TKF_TOGGLEKEYSON;
  386. }
  387. };
  388. class CShowKeyboardHelpPg : public CYesNoPg
  389. {
  390. public:
  391. CShowKeyboardHelpPg(LPPROPSHEETPAGE ppsp)
  392. : CYesNoPg(ppsp, IDS_WIZSHOWEXTRAKEYBOARDHELPTITLE, IDS_WIZSHOWEXTRAKEYBOARDHELPSUBTITLE, IDD_KBDWIZSHOWEXTRAKEYBOARDHELP) {}
  393. protected:
  394. BOOL IsOptionSet()
  395. {
  396. return g_Options.m_schemePreview.m_bShowExtraKeyboardHelp;
  397. }
  398. void SetOptions(BOOL bOn)
  399. {
  400. g_Options.m_schemePreview.m_bShowExtraKeyboardHelp = bOn;
  401. }
  402. };
  403. class CMouseSpeedPg : public WizardPage
  404. {
  405. public:
  406. CMouseSpeedPg(LPPROPSHEETPAGE ppsp)
  407. : WizardPage(ppsp, IDS_MSEWIZMOUSESPEEDTITLE, IDS_MSEWIZMOUSESPEEDSUBTITLE)
  408. {
  409. m_dwPageId = IDD_MSEWIZMOUSESPEED;
  410. ppsp->pszTemplate = MAKEINTRESOURCE(m_dwPageId);
  411. }
  412. protected:
  413. LRESULT OnInitDialog(HWND hwnd, WPARAM wParam, LPARAM lParam)
  414. {
  415. // Set slider for mouse speed, (limit 1 to 20), and set its initial value
  416. SendDlgItemMessage(m_hwnd,IDC_SLIDER1, TBM_SETRANGE, TRUE,MAKELONG(1,20));
  417. SendDlgItemMessage(m_hwnd,IDC_SLIDER1, TBM_SETPOS, TRUE, min(20, max(1, g_Options.m_schemePreview.m_nMouseSpeed)));
  418. return 1;
  419. }
  420. LRESULT HandleMsg(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  421. {
  422. switch(uMsg)
  423. {
  424. case WM_HSCROLL:
  425. g_Options.m_schemePreview.m_nMouseSpeed = (UINT)SendDlgItemMessage(m_hwnd, IDC_SLIDER1, TBM_GETPOS, 0, 0);
  426. g_Options.ApplyPreview();
  427. break;
  428. default:
  429. break;
  430. }
  431. return 0;
  432. }
  433. };
  434. class CMouseTrailsPg : public CYesNoPg
  435. {
  436. public:
  437. CMouseTrailsPg(LPPROPSHEETPAGE ppsp)
  438. : CYesNoPg(ppsp, IDS_MSEWIZMOUSETRAILSTITLE, IDS_MSEWIZMOUSETRAILSSUBTITLE, IDD_MSEWIZMOUSETRAILS) {}
  439. protected:
  440. BOOL IsOptionSet()
  441. {
  442. return (g_Options.m_schemePreview.m_nMouseTrails > 1);
  443. }
  444. void SetOptions(BOOL bOn)
  445. {
  446. g_Options.m_schemePreview.m_nMouseTrails = bOn?7:0;
  447. }
  448. };
  449. #endif // _INC_PGEXTRAS_H