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.

108 lines
2.5 KiB

  1. /****************************************************************************
  2. *
  3. * pos.c
  4. *
  5. * Copyright (c) 1991 Microsoft Corporation. All Rights Reserved.
  6. *
  7. ***************************************************************************/
  8. #include <windows.h>
  9. #include <mmsystem.h>
  10. #include "sbtest.h"
  11. /****************************************************************************
  12. *
  13. * public data
  14. *
  15. ***************************************************************************/
  16. HWND hPosWnd; // position window
  17. /****************************************************************************
  18. *
  19. * internal function prototypes
  20. *
  21. ***************************************************************************/
  22. static void Paint(HWND hWnd, HDC hDC);
  23. void CreatePosition(HWND hParent)
  24. {
  25. UINT x, y, dx, dy;
  26. x = GetSystemMetrics(SM_CXSCREEN) / 8;
  27. dx = GetSystemMetrics(SM_CXSCREEN) / 4;
  28. y = GetSystemMetrics(SM_CYSCREEN) / 3;
  29. dy = GetSystemMetrics(SM_CYCAPTION) * 5 / 2;
  30. hPosWnd = CreateWindow("POSITION",
  31. "Wave Position",
  32. WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_THICKFRAME,
  33. x, y, dx, dy,
  34. hParent,
  35. NULL,
  36. ghInst,
  37. (LPSTR)NULL);
  38. }
  39. static void Paint(HWND hWnd, HDC hDC)
  40. {
  41. MMTIME mt;
  42. char buf[20];
  43. if (hWaveOut) {
  44. mt.wType = TIME_SAMPLES;
  45. waveOutGetPosition(hWaveOut, &mt, sizeof(mt));
  46. wsprintf(buf, "%lu ", mt.u.sample);
  47. }
  48. else
  49. wsprintf(buf, "Not Playing");
  50. TextOut(hDC, 0, 0, buf, lstrlen(buf));
  51. }
  52. long FAR PASCAL PosWndProc(HWND hWnd, unsigned message, UINT wParam, LONG lParam)
  53. {
  54. PAINTSTRUCT ps; // paint structure
  55. HMENU hMenu;
  56. // process any messages we want
  57. switch (message) {
  58. case WM_CREATE:
  59. hMenu = GetMenu(hMainWnd);
  60. CheckMenuItem(hMenu, IDM_KEYBOARD, MF_CHECKED);
  61. break;
  62. case WM_PAINT:
  63. BeginPaint(hWnd, &ps);
  64. Paint(hWnd, ps.hdc);
  65. EndPaint(hWnd, &ps);
  66. break;
  67. case WM_DESTROY:
  68. hMenu = GetMenu(hMainWnd);
  69. CheckMenuItem(hMenu, IDM_KEYBOARD, MF_UNCHECKED);
  70. hPosWnd = NULL;
  71. break;
  72. default:
  73. return DefWindowProc(hWnd, message, wParam, lParam);
  74. break;
  75. }
  76. return NULL;
  77. }
  78. void ShowPos(void)
  79. {
  80. HDC hDC;
  81. if (!hPosWnd)
  82. return;
  83. hDC = GetDC(hPosWnd);
  84. Paint(hPosWnd, hDC);
  85. ReleaseDC(hPosWnd, hDC);
  86. }