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.

173 lines
5.1 KiB

  1. /*-----------------------------------------------------------------------------+
  2. | TRACK.C |
  3. | |
  4. | Contains the code which implements the track bar |
  5. | |
  6. | (C) Copyright Microsoft Corporation 1991. All rights reserved. |
  7. | |
  8. | Revision History |
  9. | Oct-1992 MikeTri Ported to WIN32 / WIN16 common code |
  10. | |
  11. +-----------------------------------------------------------------------------*/
  12. #include <windows.h>
  13. #include <mmsystem.h>
  14. #include <windowsx.h>
  15. #include "mplayer.h"
  16. #include "toolbar.h"
  17. #include "tracki.h"
  18. WNDPROC fnTrackbarWndProc = NULL;
  19. /* TB_OnKey
  20. *
  21. * Handles WM_KEYDOWN and WM_KEYUP messages.
  22. *
  23. * If the shift key is pressed while we're playing or scrolling
  24. * treat it as a start selection. End the selection on the key-up
  25. * message.
  26. *
  27. * Clear any selection if the escape key is pressed.
  28. *
  29. */
  30. void TB_OnKey(HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags)
  31. {
  32. int cmd = -1;
  33. switch(vk)
  34. {
  35. case VK_SHIFT:
  36. /* Check that the key wasn't already down:
  37. */
  38. if (fDown && !(flags & 0x4000))
  39. {
  40. if(((gwStatus == MCI_MODE_PLAY) || gfScrollTrack)
  41. &&(toolbarStateFromButton(ghwndMark, BTN_MARKIN, TBINDEX_MARK)
  42. != BTNST_GRAYED))
  43. SendMessage(hwnd, WM_COMMAND, IDT_MARKIN, 0);
  44. }
  45. /* If !fDown, it must be fUp:
  46. */
  47. else if (!fDown)
  48. {
  49. if (SendMessage(ghwndTrackbar, TBM_GETSELSTART, 0, 0) != -1)
  50. SendMessage(hwnd, WM_COMMAND, IDT_MARKOUT, 0);
  51. }
  52. break;
  53. case VK_ESCAPE:
  54. SendMessage(ghwndTrackbar, TBM_CLEARSEL, (WPARAM)TRUE, 0);
  55. break;
  56. default:
  57. if (fDown)
  58. {
  59. // Don't do this, because the common-control trackbar sends us
  60. // WM_HSCROLL in response to this, which causes us to increment twice:
  61. // FORWARD_WM_KEYDOWN(hwnd, vk, cRepeat, flags, fnTrackbarWndProc);
  62. switch (vk)
  63. {
  64. case VK_HOME:
  65. cmd = TB_TOP;
  66. break;
  67. case VK_END:
  68. cmd = TB_BOTTOM;
  69. break;
  70. case VK_PRIOR:
  71. cmd = TB_PAGEUP;
  72. break;
  73. case VK_NEXT:
  74. cmd = TB_PAGEDOWN;
  75. break;
  76. case VK_LEFT:
  77. case VK_UP:
  78. cmd = TB_LINEUP;
  79. break;
  80. case VK_RIGHT:
  81. case VK_DOWN:
  82. cmd = TB_LINEDOWN;
  83. break;
  84. default:
  85. break;
  86. }
  87. }
  88. else
  89. {
  90. FORWARD_WM_KEYUP(hwnd, vk, cRepeat, flags, fnTrackbarWndProc);
  91. return;
  92. }
  93. if (cmd != -1)
  94. SendMessage(GetParent(hwnd), WM_HSCROLL, MAKELONG(cmd, 0), (LPARAM)hwnd);
  95. }
  96. }
  97. /* Subclass the window so that we can handle the key presses
  98. * we're interested in.
  99. */
  100. /* TBWndProc() */
  101. LONG_PTR FAR PASCAL
  102. SubClassedTrackbarWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  103. {
  104. switch (message)
  105. {
  106. HANDLE_MSG(hwnd, WM_KEYDOWN, TB_OnKey);
  107. HANDLE_MSG(hwnd, WM_KEYUP, TB_OnKey);
  108. /* HACK ALERT
  109. *
  110. * This is to get around a bug in the Chicago common control trackbar,
  111. * which is sending too many TB_ENDTRACK notifications.
  112. * It sends one when it receives WM_CAPTURECHANGED, even if it called
  113. * ReleaseCapture itself.
  114. * So, if we're not currently scrolling, ignore it.
  115. */
  116. case WM_CAPTURECHANGED:
  117. if (!gfScrollTrack)
  118. return 0;
  119. case TBM_SHOWTICS:
  120. /* If we're hiding the ticks, we want a chiseled thumb,
  121. * so make it TBS_BOTH as well as TBS_NOTICKS.
  122. */
  123. if (wParam == TRUE)
  124. SetWindowLongPtr(hwnd, GWL_STYLE,
  125. (GetWindowLongPtr(hwnd, GWL_STYLE) & ~(TBS_NOTICKS | TBS_BOTH)));
  126. else
  127. SetWindowLongPtr(hwnd, GWL_STYLE,
  128. (GetWindowLongPtr(hwnd, GWL_STYLE) | TBS_NOTICKS | TBS_BOTH));
  129. if (lParam == TRUE)
  130. InvalidateRect(hwnd, NULL, TRUE);
  131. return 0;
  132. }
  133. return CallWindowProc(fnTrackbarWndProc, hwnd, message, wParam, lParam);
  134. }
  135. void SubClassTrackbarWindow()
  136. {
  137. if (!fnTrackbarWndProc)
  138. fnTrackbarWndProc = (WNDPROC)GetWindowLongPtr(ghwndTrackbar, GWLP_WNDPROC);
  139. if (ghwndTrackbar)
  140. SetWindowLongPtr(ghwndTrackbar, GWLP_WNDPROC, (LONG_PTR)SubClassedTrackbarWndProc);
  141. }