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.

356 lines
11 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. tuning.c
  5. Abstract: Tablet PC Gesture Tuning Parameters Property Sheet module.
  6. Environment:
  7. User mode
  8. Author:
  9. Michael Tsang (MikeTs) 20-Jul-2000
  10. Revision History:
  11. --*/
  12. #include "pch.h"
  13. #ifdef DEBUG
  14. #define MAX_VALUE 999
  15. DWORD gTuningHelpIDs[] =
  16. {
  17. 0, 0
  18. };
  19. /*****************************************************************************
  20. *
  21. * @doc EXTERNAL
  22. *
  23. * @func INT_PTR | TuningDlgProc |
  24. * Dialog procedure for the gesture tuning page.
  25. *
  26. * @parm IN HWND | hwnd | Window handle.
  27. * @parm IN UINT | uMsg | Message.
  28. * @parm IN WPARAM | wParam | Word Parameter.
  29. * @parm IN LPARAM | lParam | Long Parameter.
  30. *
  31. * @rvalue Return value depends on the message.
  32. *
  33. *****************************************************************************/
  34. INT_PTR APIENTRY
  35. TuningDlgProc(
  36. IN HWND hwnd,
  37. IN UINT uMsg,
  38. IN WPARAM wParam,
  39. IN LPARAM lParam
  40. )
  41. {
  42. TRACEPROC("TuningDlgProc", 2)
  43. INT_PTR rc = FALSE;
  44. static BOOL fInitDone = FALSE;
  45. TRACEENTER(("(hwnd=%p,Msg=%s,wParam=%x,lParam=%x)\n",
  46. hwnd, LookupName(uMsg, WMMsgNames), wParam, lParam));
  47. switch (uMsg)
  48. {
  49. case WM_INITDIALOG:
  50. rc = InitTuningPage(hwnd);
  51. if (rc == FALSE)
  52. {
  53. EnableWindow(hwnd, FALSE);
  54. }
  55. else
  56. {
  57. fInitDone = TRUE;
  58. }
  59. break;
  60. case WM_NOTIFY:
  61. {
  62. NMHDR FAR *lpnm = (NMHDR FAR *)lParam;
  63. switch (lpnm->code)
  64. {
  65. case PSN_APPLY:
  66. RPC_TRY("TabSrvSetGestureFeatures",
  67. rc = TabSrvSetGestureSettings(ghBinding,
  68. &gGestureSettings));
  69. if (rc == FALSE)
  70. {
  71. ErrorMsg(IDSERR_TABSRV_SETGESTURESETTINGS);
  72. }
  73. rc = TRUE;
  74. break;
  75. }
  76. break;
  77. }
  78. case WM_COMMAND:
  79. {
  80. int *piValue;
  81. switch (LOWORD(wParam))
  82. {
  83. case IDC_GESTURE_RADIUS:
  84. piValue = &gGestureSettings.iRadius;
  85. goto TuningCommon;
  86. case IDC_GESTURE_MINOUTPTS:
  87. piValue = &gGestureSettings.iMinOutPts;
  88. goto TuningCommon;
  89. case IDC_GESTURE_MAXTIMETOINSPECT:
  90. piValue = &gGestureSettings.iMaxTimeToInspect;
  91. goto TuningCommon;
  92. case IDC_GESTURE_ASPECTRATIO:
  93. piValue = &gGestureSettings.iAspectRatio;
  94. goto TuningCommon;
  95. case IDC_GESTURE_CHECKTIME:
  96. piValue = &gGestureSettings.iCheckTime;
  97. goto TuningCommon;
  98. case IDC_GESTURE_PTSTOEXAMINE:
  99. piValue = &gGestureSettings.iPointsToExamine;
  100. goto TuningCommon;
  101. case IDC_GESTURE_STOPDIST:
  102. piValue = &gGestureSettings.iStopDist;
  103. goto TuningCommon;
  104. case IDC_GESTURE_STOPTIME:
  105. piValue = &gGestureSettings.iStopTime;
  106. goto TuningCommon;
  107. case IDC_PRESSHOLD_HOLDTIME:
  108. piValue = &gGestureSettings.iPressHoldTime;
  109. goto TuningCommon;
  110. case IDC_PRESSHOLD_TOLERANCE:
  111. piValue = &gGestureSettings.iHoldTolerance;
  112. goto TuningCommon;
  113. case IDC_PRESSHOLD_CANCELTIME:
  114. piValue = &gGestureSettings.iCancelPressHoldTime;
  115. TuningCommon:
  116. switch (HIWORD(wParam))
  117. {
  118. case EN_UPDATE:
  119. {
  120. int n;
  121. BOOL fOK;
  122. n = GetDlgItemInt(hwnd,
  123. LOWORD(wParam),
  124. &fOK,
  125. FALSE);
  126. if (fOK && (n <= MAX_VALUE))
  127. {
  128. *piValue = n;
  129. SendMessage(GetParent(hwnd), PSM_CHANGED, (WPARAM)hwnd, 0);
  130. }
  131. else if (fInitDone)
  132. {
  133. SetDlgItemInt(hwnd,
  134. LOWORD(wParam),
  135. *piValue,
  136. FALSE);
  137. SendMessage((HWND)lParam,
  138. EM_SETSEL,
  139. 0,
  140. -1);
  141. MessageBeep(MB_ICONEXCLAMATION);
  142. }
  143. break;
  144. }
  145. }
  146. break;
  147. }
  148. break;
  149. }
  150. case WM_HELP:
  151. WinHelp((HWND)((LPHELPINFO)lParam)->hItemHandle,
  152. TEXT("tabletpc.hlp"),
  153. HELP_WM_HELP,
  154. (DWORD_PTR)gTuningHelpIDs);
  155. break;
  156. case WM_CONTEXTMENU:
  157. WinHelp((HWND)wParam,
  158. TEXT("tabletpc.hlp"),
  159. HELP_CONTEXTMENU,
  160. (DWORD_PTR)gTuningHelpIDs);
  161. break;
  162. }
  163. TRACEEXIT(("=%x\n", rc));
  164. return rc;
  165. } //GestureDlgProc
  166. /*****************************************************************************
  167. *
  168. * @doc INTERNAL
  169. *
  170. * @func BOOL | InitTuningPage |
  171. * Initialize the Gesture property page.
  172. *
  173. * @parm IN HWND | hwnd | Window handle.
  174. *
  175. * @rvalue SUCCESS | Returns TRUE.
  176. * @rvalue FAILURE | Returns FALSE.
  177. *
  178. *****************************************************************************/
  179. BOOL
  180. InitTuningPage(
  181. IN HWND hwnd
  182. )
  183. {
  184. TRACEPROC("InitTuningPage", 2)
  185. BOOL rc;
  186. TRACEENTER(("(hwnd=%x)\n", hwnd));
  187. RPC_TRY("TabSrvGetGestureSettings",
  188. rc = TabSrvGetGestureSettings(ghBinding,
  189. &gGestureSettings));
  190. if (rc == TRUE)
  191. {
  192. SendDlgItemMessage(hwnd,
  193. IDC_GESTURE_RADIUS_SPIN,
  194. UDM_SETRANGE32,
  195. 0,
  196. MAX_VALUE);
  197. SendDlgItemMessage(hwnd,
  198. IDC_GESTURE_MINOUTPTS_SPIN,
  199. UDM_SETRANGE32,
  200. 0,
  201. MAX_VALUE);
  202. SendDlgItemMessage(hwnd,
  203. IDC_GESTURE_MAXTIMETOINSPECT_SPIN,
  204. UDM_SETRANGE32,
  205. 0,
  206. MAX_VALUE);
  207. SendDlgItemMessage(hwnd,
  208. IDC_GESTURE_ASPECTRATIO_SPIN,
  209. UDM_SETRANGE32,
  210. 0,
  211. MAX_VALUE);
  212. SendDlgItemMessage(hwnd,
  213. IDC_GESTURE_CHECKTIME_SPIN,
  214. UDM_SETRANGE32,
  215. 0,
  216. MAX_VALUE);
  217. SendDlgItemMessage(hwnd,
  218. IDC_GESTURE_PTSTOEXAMINE_SPIN,
  219. UDM_SETRANGE32,
  220. 0,
  221. MAX_VALUE);
  222. SendDlgItemMessage(hwnd,
  223. IDC_GESTURE_STOPDIST_SPIN,
  224. UDM_SETRANGE32,
  225. 0,
  226. MAX_VALUE);
  227. SendDlgItemMessage(hwnd,
  228. IDC_GESTURE_STOPTIME_SPIN,
  229. UDM_SETRANGE32,
  230. 0,
  231. MAX_VALUE);
  232. SendDlgItemMessage(hwnd,
  233. IDC_GESTURE_RADIUS_SPIN,
  234. UDM_SETPOS32,
  235. 0,
  236. gGestureSettings.iRadius);
  237. SendDlgItemMessage(hwnd,
  238. IDC_GESTURE_MINOUTPTS_SPIN,
  239. UDM_SETPOS32,
  240. 0,
  241. gGestureSettings.iMinOutPts);
  242. SendDlgItemMessage(hwnd,
  243. IDC_GESTURE_MAXTIMETOINSPECT_SPIN,
  244. UDM_SETPOS32,
  245. 0,
  246. gGestureSettings.iMaxTimeToInspect);
  247. SendDlgItemMessage(hwnd,
  248. IDC_GESTURE_ASPECTRATIO_SPIN,
  249. UDM_SETPOS32,
  250. 0,
  251. gGestureSettings.iAspectRatio);
  252. SendDlgItemMessage(hwnd,
  253. IDC_GESTURE_CHECKTIME_SPIN,
  254. UDM_SETPOS32,
  255. 0,
  256. gGestureSettings.iCheckTime);
  257. SendDlgItemMessage(hwnd,
  258. IDC_GESTURE_PTSTOEXAMINE_SPIN,
  259. UDM_SETPOS32,
  260. 0,
  261. gGestureSettings.iPointsToExamine);
  262. SendDlgItemMessage(hwnd,
  263. IDC_GESTURE_STOPDIST_SPIN,
  264. UDM_SETPOS32,
  265. 0,
  266. gGestureSettings.iStopDist);
  267. SendDlgItemMessage(hwnd,
  268. IDC_GESTURE_STOPTIME_SPIN,
  269. UDM_SETPOS32,
  270. 0,
  271. gGestureSettings.iStopTime);
  272. SendDlgItemMessage(hwnd,
  273. IDC_PRESSHOLD_HOLDTIME_SPIN,
  274. UDM_SETRANGE32,
  275. 0,
  276. MAX_VALUE);
  277. SendDlgItemMessage(hwnd,
  278. IDC_PRESSHOLD_TOLERANCE_SPIN,
  279. UDM_SETRANGE32,
  280. 0,
  281. MAX_VALUE);
  282. SendDlgItemMessage(hwnd,
  283. IDC_PRESSHOLD_CANCELTIME_SPIN,
  284. UDM_SETRANGE32,
  285. 0,
  286. MAX_VALUE);
  287. SendDlgItemMessage(hwnd,
  288. IDC_PRESSHOLD_HOLDTIME_SPIN,
  289. UDM_SETPOS32,
  290. 0,
  291. gGestureSettings.iPressHoldTime);
  292. SendDlgItemMessage(hwnd,
  293. IDC_PRESSHOLD_TOLERANCE_SPIN,
  294. UDM_SETPOS32,
  295. 0,
  296. gGestureSettings.iHoldTolerance);
  297. SendDlgItemMessage(hwnd,
  298. IDC_PRESSHOLD_CANCELTIME_SPIN,
  299. UDM_SETPOS32,
  300. 0,
  301. gGestureSettings.iCancelPressHoldTime);
  302. }
  303. else
  304. {
  305. ErrorMsg(IDSERR_TABSRV_GETGESTURESETTINGS);
  306. }
  307. TRACEEXIT(("=%x\n", rc));
  308. return rc;
  309. } //InitTuningPage
  310. #endif //ifdef DEBUG