ReactOS  0.4.12-dev-102-g4b7f1e0
mplay32.c File Reference
#include "mplay32.h"
Include dependency graph for mplay32.c:

Go to the source code of this file.

Macros

#define IDT_PLAYTIMER   1000
 
#define MAIN_WINDOW_HEIGHT   125
 
#define MAIN_WINDOW_MIN_WIDTH   250
 
#define MAX_MCISTR   256
 

Functions

static DWORD GetDeviceMode (HWND hwnd)
 
void EnableMenuItems (HWND hwnd)
 
void DisableMenuItems (void)
 
void ResizeClientArea (HWND hwnd, int nWidth, int nHeight)
 
void UpdateWindowCaption (HWND hwnd)
 
void UpdateTimeDisplay (HWND hwnd)
 
static VOID ShowLastWin32Error (HWND hwnd)
 
static VOID SetImageList (HWND hwnd)
 
static VOID ShowMCIError (HWND hwnd, MCIERROR mciError)
 
static VOID InitControls (HWND hwnd)
 
static VOID SwitchViewMode (HWND hwnd)
 
static DWORD GetNumDevices (VOID)
 
static DWORD GetDeviceName (DWORD dwDeviceIndex, LPTSTR lpDeviceName, DWORD dwDeviceNameSize)
 
static DWORD GetDeviceFriendlyName (LPTSTR lpDeviceName, LPTSTR lpFriendlyName, DWORD dwFriendlyNameSize)
 
static BOOL DeviceUsesFiles (LPTSTR lpDeviceName)
 
static MCIERROR CloseMciDevice (VOID)
 
static MCIERROR OpenMciDevice (HWND hwnd, LPTSTR lpType, LPTSTR lpFileName)
 
static VOID StopPlayback (HWND hwnd)
 
static VOID SeekPlayback (HWND hwnd, DWORD dwNewPos)
 
static VOID SeekBackPlayback (HWND hwnd)
 
static VOID SeekForwPlayback (HWND hwnd)
 
VOID CALLBACK PlayTimerProc (HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
 
static VOID StartPlayback (HWND hwnd)
 
static VOID TogglePlaybackState (HWND hwnd)
 
static VOID ShowDeviceProperties (HWND hwnd)
 
static VOID CloseMediaFile (HWND hwnd)
 
static VOID OpenMediaFile (HWND hwnd, LPTSTR lpFileName, LPTSTR lpType)
 
static DWORD InsertDeviceMenuItem (HMENU hMenu, UINT uItem, BOOL fByPosition, UINT uItemID, DWORD dwDeviceIndex)
 
static VOID BuildFileFilterAndDeviceMenu (VOID)
 
static VOID CleanupFileFilter (VOID)
 
static VOID OpenFileDialog (HWND hwnd, DWORD dwFilterIndex, LPTSTR lpType)
 
static VOID HandleDeviceMenuItem (HWND hwnd, UINT uItem)
 
LRESULT CALLBACK MainWndProc (HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
 
INT WINAPI _tWinMain (HINSTANCE hInst, HINSTANCE hPrevInst, LPTSTR lpCmdLine, INT nCmdShow)
 

Variables

HINSTANCE hInstance = NULL
 
HWND hTrackBar = NULL
 
HWND hToolBar = NULL
 
HWND hTimeDisplay = NULL
 
HMENU hMainMenu = NULL
 
TCHAR szAppTitle [256] = _T("")
 
TCHAR szDefaultFilter [MAX_PATH] = _T("")
 
TCHAR szCurrentFile [MAX_PATH] = _T("")
 
LPTSTR szFilter = NULL
 
WORD wDeviceId = 0
 
BOOL bRepeat = FALSE
 
BOOL bIsSingleWindow = FALSE
 
UINT MaxFilePos = 0
 
RECT PrevWindowPos
 
static const TBBUTTON Buttons []
 

Macro Definition Documentation

◆ IDT_PLAYTIMER

#define IDT_PLAYTIMER   1000

Definition at line 9 of file mplay32.c.

Referenced by PlayTimerProc(), StartPlayback(), and StopPlayback().

◆ MAIN_WINDOW_HEIGHT

#define MAIN_WINDOW_HEIGHT   125

Definition at line 11 of file mplay32.c.

Referenced by _tWinMain(), and MainWndProc().

◆ MAIN_WINDOW_MIN_WIDTH

#define MAIN_WINDOW_MIN_WIDTH   250

Definition at line 12 of file mplay32.c.

Referenced by MainWndProc().

◆ MAX_MCISTR

Function Documentation

◆ _tWinMain()

INT WINAPI _tWinMain ( HINSTANCE  hInst,
HINSTANCE  hPrevInst,
LPTSTR  lpCmdLine,
INT  nCmdShow 
)

Definition at line 1466 of file mplay32.c.

1467 {
1468  WNDCLASSEX WndClass = {0};
1469  TCHAR szClassName[] = _T("ROSMPLAY32");
1470  HWND hwnd;
1471  MSG msg;
1472  DWORD dwError;
1473  HANDLE hAccel;
1474 
1475  hInstance = hInst;
1476 
1477  switch (GetUserDefaultUILanguage())
1478  {
1481  break;
1482 
1483  default:
1484  break;
1485  }
1486 
1488 
1489  WndClass.cbSize = sizeof(WndClass);
1490  WndClass.lpszClassName = szClassName;
1491  WndClass.lpfnWndProc = MainWndProc;
1492  WndClass.hInstance = hInstance;
1493  WndClass.style = CS_HREDRAW | CS_VREDRAW;
1495  WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
1496  WndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
1498 
1499  if (!RegisterClassEx(&WndClass))
1500  {
1502  return 0;
1503  }
1504 
1505  hwnd = CreateWindow(szClassName,
1506  szAppTitle,
1508  CW_USEDEFAULT,
1509  CW_USEDEFAULT,
1510  350,
1512  NULL,
1513  NULL,
1514  hInstance,
1515  NULL);
1516  if (!hwnd)
1517  {
1519  return 0;
1520  }
1521 
1523 
1525 
1526  DragAcceptFiles(hwnd, TRUE);
1527 
1528  DisableMenuItems();
1529 
1530  dwError = SearchPath(NULL, _T("SNDVOL32.EXE"), NULL, 0, NULL, NULL);
1531  if (dwError == 0)
1532  {
1534  }
1535 
1536  /* Show it */
1537  ShowWindow(hwnd, SW_SHOW);
1538  UpdateWindow(hwnd);
1539 
1540  OpenMediaFile(hwnd, lpCmdLine, NULL);
1541 
1542  /* Message Loop */
1543  while (GetMessage(&msg, NULL, 0, 0))
1544  {
1545  if (!TranslateAccelerator(hwnd, hAccel, &msg))
1546  {
1547  TranslateMessage(&msg);
1548  DispatchMessage(&msg);
1549  }
1550  }
1551 
1553 
1554  DestroyAcceleratorTable(hAccel);
1555 
1556  return (INT)msg.wParam;
1557 }
#define WS_THICKFRAME
Definition: pedump.c:630
#define TranslateAccelerator
Definition: winuser.h:5726
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
UINT style
Definition: winuser.h:3155
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define IDR_MAINMENU
Definition: resource.h:40
#define DispatchMessage
Definition: winuser.h:5631
LANGID WINAPI GetUserDefaultUILanguage(void)
Definition: lang.c:561
BOOL WINAPI TranslateMessage(_In_ const MSG *)
LPCSTR lpszMenuName
Definition: winuser.h:3163
#define TRUE
Definition: types.h:120
#define RegisterClassEx
Definition: winuser.h:5703
#define MF_BYCOMMAND
Definition: winuser.h:202
#define LAYOUT_RTL
Definition: wingdi.h:1352
HCURSOR hCursor
Definition: winuser.h:3161
WNDPROC lpfnWndProc
Definition: winuser.h:3156
#define CreateWindow
Definition: winuser.h:5620
#define IDS_APPTITLE
Definition: resource.h:3
static VOID BuildFileFilterAndDeviceMenu(VOID)
Definition: mplay32.c:945
LPCSTR lpszClassName
Definition: winuser.h:3164
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define SUBLANG_DEFAULT
Definition: nls.h:168
BOOL WINAPI UpdateWindow(_In_ HWND)
void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
Definition: shellole.c:527
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define CS_HREDRAW
Definition: winuser.h:648
HINSTANCE hInstance
Definition: mplay32.c:15
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define WS_CLIPCHILDREN
Definition: pedump.c:619
int32_t INT
Definition: typedefs.h:56
#define LANG_HEBREW
Definition: nls.h:67
#define SearchPath
Definition: winbase.h:3714
static VOID ShowLastWin32Error(HWND hwnd)
Definition: mplay32.c:207
#define MAIN_WINDOW_HEIGHT
Definition: mplay32.c:11
HMENU hMainMenu
Definition: mplay32.c:19
#define LoadAccelerators
Definition: winuser.h:5676
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define ID_ACCELERATORS
Definition: resource.h:43
HINSTANCE hInstance
Definition: winuser.h:3159
HACCEL hAccel
Definition: main.c:47
#define CW_USEDEFAULT
Definition: winuser.h:225
smooth NULL
Definition: ftsmooth.c:416
static VOID CleanupFileFilter(VOID)
Definition: mplay32.c:1136
UINT cbSize
Definition: winuser.h:3154
void DisableMenuItems(void)
Definition: mplay32.c:76
#define SW_SHOW
Definition: winuser.h:769
static VOID OpenMediaFile(HWND hwnd, LPTSTR lpFileName, LPTSTR lpType)
Definition: mplay32.c:887
HBRUSH hbrBackground
Definition: winuser.h:3162
BOOL WINAPI SetProcessDefaultLayout(DWORD dwDefaultLayout)
Definition: window.c:1686
#define WS_CAPTION
Definition: pedump.c:624
#define CS_VREDRAW
Definition: winuser.h:653
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
Definition: mplay32.c:1207
static const WCHAR szClassName[]
Definition: clipbrd.c:11
#define WS_OVERLAPPED
Definition: pedump.c:615
TCHAR szAppTitle[256]
Definition: mplay32.c:21
unsigned long DWORD
Definition: ntddk_ex.h:95
HICON hIcon
Definition: winuser.h:3160
#define IDI_MAIN
Definition: resource.h:4
#define COLOR_BTNFACE
Definition: winuser.h:918
#define LoadCursor
Definition: winuser.h:5678
HINSTANCE hInst
Definition: dxdiag.c:13
BOOL WINAPI DestroyAcceleratorTable(_In_ HACCEL)
#define WS_MINIMIZEBOX
Definition: pedump.c:631
#define GetMessage
Definition: winuser.h:5656
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
#define IDM_VOLUMECTL
Definition: resource.h:50
#define MAKELANGID(p, s)
Definition: nls.h:15
#define LoadIcon
Definition: winuser.h:5679
#define MF_GRAYED
Definition: winuser.h:129
#define WS_SYSMENU
Definition: pedump.c:629
#define LoadString
Definition: winuser.h:5685
WCHAR WndClass[]
Definition: capicon.c:23

◆ BuildFileFilterAndDeviceMenu()

static VOID BuildFileFilterAndDeviceMenu ( VOID  )
static

Definition at line 945 of file mplay32.c.

Referenced by _tWinMain().

946 {
948  TCHAR szFriendlyName[MAX_MCISTR];
949  TCHAR *szDevice = NULL;
950  static TCHAR szDefaultExtension[] = _T("*.*");
951  TCHAR *szExtensionList = NULL;
952  TCHAR *szExtension = NULL;
953  TCHAR *c = NULL;
954  TCHAR *d = NULL;
955  DWORD dwNumValues;
956  DWORD dwNumDevices;
957  DWORD dwValueNameLen;
958  DWORD dwValueDataSize;
959  DWORD dwMaskLen;
960  DWORD dwFilterSize;
961  DWORD dwDeviceSize;
962  DWORD dwExtensionLen;
963  DWORD dwPosition = 0;
964  DWORD i;
965  DWORD j;
966  size_t uSizeRemain;
967  size_t uMaskRemain;
968  HKEY hKey = NULL;
969 
970  /* Always load the default (all files) filter */
972 
973  if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\MCI Extensions"), 0, KEY_READ, &hKey) != ERROR_SUCCESS)
974  {
975  goto Failure;
976  }
977 
978  if (RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, &dwNumValues, &dwValueNameLen, &dwValueDataSize, NULL, NULL) != ERROR_SUCCESS)
979  {
980  goto Failure;
981  }
982 
983  dwMaskLen = ((dwValueNameLen + 3) * dwNumValues) + 1;
984 
985  szExtensionList = malloc(dwMaskLen * sizeof(TCHAR));
986  if (!szExtensionList)
987  goto Failure;
988 
989  dwNumDevices = GetNumDevices();
990 
991  /* Allocate space for every pair of Device and Extension Filter */
992  dwFilterSize = (MAX_MCISTR + (dwMaskLen * 2) + 5) * dwNumDevices;
993 
994  /* Add space for the "All supported" entry */
995  dwFilterSize = (dwFilterSize + (dwMaskLen * 2) + 7) * sizeof(TCHAR) + sizeof(szDefaultFilter);
996 
997  szFilter = malloc(dwFilterSize);
998  if (!szFilter)
999  goto Failure;
1000 
1001  szExtension = malloc((dwValueNameLen + 1) * sizeof(TCHAR));
1002  if (!szExtension)
1003  goto Failure;
1004 
1005  szDevice = malloc(dwValueDataSize + sizeof(TCHAR));
1006  if (!szDevice)
1007  goto Failure;
1008 
1009  ZeroMemory(szFilter, dwFilterSize);
1010 
1011  uSizeRemain = dwFilterSize;
1012  c = szFilter;
1013 
1014  for (j = 1; j <= dwNumDevices; j++)
1015  {
1016  if (GetDeviceName(j, szDeviceName, sizeof(szDeviceName)))
1017  {
1018  continue;
1019  }
1020 
1021  if (GetDeviceFriendlyName(szDeviceName, szFriendlyName, sizeof(szFriendlyName)))
1022  {
1023  continue;
1024  }
1025 
1026  /* Insert a menu item under the "Device" menu for every found MCI device */
1027  InsertDeviceMenuItem(GetSubMenu(hMainMenu, 3), dwPosition, TRUE, IDM_DEVICE_FIRST + dwPosition, j);
1028  dwPosition++;
1029 
1030  /* Copy the default extension list, that may be overwritten after... */
1031  StringCbCopy(szExtensionList, dwMaskLen * sizeof(TCHAR), szDefaultExtension);
1032 
1033  /* Try to determine the real extension list */
1034  uMaskRemain = dwMaskLen * sizeof(TCHAR);
1035  d = szExtensionList;
1036 
1037  for (i = 0; i < dwNumValues; i++)
1038  {
1039  dwExtensionLen = dwValueNameLen + 1;
1040  dwDeviceSize = dwValueDataSize + sizeof(TCHAR);
1041 
1042  ZeroMemory(szDevice, dwDeviceSize);
1043 
1044  if (RegEnumValue(hKey, i, szExtension, &dwExtensionLen, NULL, NULL, (LPBYTE)szDevice, &dwDeviceSize) == ERROR_SUCCESS)
1045  {
1046  CharLowerBuff(szDevice, dwDeviceSize / sizeof(TCHAR));
1047  CharLowerBuff(szDeviceName, ARRAYSIZE(szDeviceName));
1048  if (_tcscmp(szDeviceName, szDevice) == 0)
1049  {
1050  CharLowerBuff(szExtension, dwExtensionLen);
1051  StringCbPrintfEx(d, uMaskRemain, &d, &uMaskRemain, 0, _T("%s%s%s"), _T("*."), szExtension, _T(";"));
1052  }
1053  }
1054  }
1055 
1056  /* Remove the last separator */
1057  d--;
1058  uSizeRemain += sizeof(*d);
1059  *d = _T('\0');
1060 
1061  /* Add the description */
1062  StringCbPrintfEx(c, uSizeRemain, &c, &uSizeRemain, 0, _T("%s (%s)"), szFriendlyName, szExtensionList);
1063 
1064  /* Skip one char to separate the description from the filter mask */
1065  c++;
1066  uSizeRemain -= sizeof(*c);
1067 
1068  /* Append the filter mask */
1069  StringCbCopyEx(c, uSizeRemain, szExtensionList, &c, &uSizeRemain, 0);
1070 
1071  /* Skip another char to separate the elements of the filter mask */
1072  c++;
1073  uSizeRemain -= sizeof(*c);
1074  }
1075 
1076  /* Build the full list of supported extensions */
1077  uMaskRemain = dwMaskLen * sizeof(TCHAR);
1078  d = szExtensionList;
1079 
1080  for (i = 0; i < dwNumValues; i++)
1081  {
1082  dwExtensionLen = dwValueNameLen + 1;
1083 
1084  if (RegEnumValue(hKey, i, szExtension, &dwExtensionLen, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
1085  {
1086  CharLowerBuff(szExtension, dwExtensionLen);
1087  StringCbPrintfEx(d, uMaskRemain, &d, &uMaskRemain, 0, _T("%s%s%s"), _T("*."), szExtension, _T(";"));
1088  }
1089  }
1090 
1091  /* Remove the last separator */
1092  d--;
1093  uSizeRemain += sizeof(*d);
1094  *d = _T('\0');
1095 
1096  /* Add the default (all files) description */
1097  StringCbPrintfEx(c, uSizeRemain, &c, &uSizeRemain, 0, _T("%s (%s)"), szDefaultFilter, szExtensionList);
1098 
1099  /* Skip one char to separate the description from the filter mask */
1100  c++;
1101  uSizeRemain -= sizeof(*c);
1102 
1103  /* Append the filter mask */
1104  StringCbCopyEx(c, uSizeRemain, szExtensionList, &c, &uSizeRemain, 0);
1105 
1106 Cleanup:
1107  if (szExtensionList) free(szExtensionList);
1108  if (szExtension) free(szExtension);
1109  if (szDevice) free(szDevice);
1110  RegCloseKey(hKey);
1111 
1112  return;
1113 
1114 Failure:
1115  /* We failed at retrieving the supported files, so use the default filter */
1116  if (szFilter) free(szFilter);
1118 
1119  uSizeRemain = sizeof(szDefaultFilter);
1120  c = szFilter;
1121 
1122  /* Add the default (all files) description */
1123  StringCbPrintfEx(c, uSizeRemain, &c, &uSizeRemain, 0, _T("%s (%s)"), szDefaultFilter, szDefaultExtension);
1124 
1125  /* Skip one char to separate the description from the filter mask */
1126  c++;
1127  uSizeRemain -= sizeof(*c);
1128 
1129  /* Append the filter mask */
1130  StringCbCopyEx(c, uSizeRemain, szDefaultExtension, &c, &uSizeRemain, 0);
1131 
1132  goto Cleanup;
1133 }
#define CharLowerBuff
Definition: winuser.h:5604
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
#define TRUE
Definition: types.h:120
static DWORD GetDeviceName(DWORD dwDeviceIndex, LPTSTR lpDeviceName, DWORD dwDeviceNameSize)
Definition: mplay32.c:450
#define RegQueryInfoKey
Definition: winreg.h:521
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
#define free
Definition: debug_ros.c:5
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define ZeroMemory
Definition: winbase.h:1635
HINSTANCE hInstance
Definition: mplay32.c:15
HMENU hMainMenu
Definition: mplay32.c:19
GLenum GLclampf GLint i
Definition: glfuncs.h:14
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define StringCbPrintfEx
Definition: strsafe.h:600
smooth NULL
Definition: ftsmooth.c:416
LPTSTR szFilter
Definition: mplay32.c:24
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define d
Definition: ke_i.h:81
const GLubyte * c
Definition: glext.h:8905
unsigned long DWORD
Definition: ntddk_ex.h:95
static DWORD GetNumDevices(VOID)
Definition: mplay32.c:433
#define StringCbCopy
Definition: strsafe.h:155
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
static const WCHAR szDeviceName[]
Definition: provider.c:53
static const WCHAR Cleanup[]
Definition: register.c:80
#define IDS_ALL_TYPES_FILTER
Definition: resource.h:26
static DWORD GetDeviceFriendlyName(LPTSTR lpDeviceName, LPTSTR lpFriendlyName, DWORD dwFriendlyNameSize)
Definition: mplay32.c:464
#define RegOpenKeyEx
Definition: winreg.h:520
#define MAX_MCISTR
Definition: mplay32.c:13
#define StringCbCopyEx
Definition: strsafe.h:192
#define IDM_DEVICE_FIRST
Definition: resource.h:56
static DWORD InsertDeviceMenuItem(HMENU hMenu, UINT uItem, BOOL fByPosition, UINT uItemID, DWORD dwDeviceIndex)
Definition: mplay32.c:908
#define malloc
Definition: debug_ros.c:4
LONG RegEnumValue(HKEY Key, ULONG Index, PWCHAR ValueName, ULONG *NameSize, ULONG *Type, PUCHAR Data, ULONG *DataSize)
TCHAR szDefaultFilter[MAX_PATH]
Definition: mplay32.c:22
#define LoadString
Definition: winuser.h:5685
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

◆ CleanupFileFilter()

static VOID CleanupFileFilter ( VOID  )
static

Definition at line 1136 of file mplay32.c.

Referenced by _tWinMain().

1137 {
1139 }
#define free
Definition: debug_ros.c:5
LPTSTR szFilter
Definition: mplay32.c:24
TCHAR szDefaultFilter[MAX_PATH]
Definition: mplay32.c:22

◆ CloseMciDevice()

static MCIERROR CloseMciDevice ( VOID  )
static

Definition at line 526 of file mplay32.c.

Referenced by CloseMediaFile(), and OpenMciDevice().

527 {
528  MCIERROR mciError;
529  MCI_GENERIC_PARMS mciGeneric;
530 
531  if (wDeviceId)
532  {
533  mciError = mciSendCommand(wDeviceId, MCI_CLOSE, MCI_WAIT, (DWORD_PTR)&mciGeneric);
534  if (mciError != 0) return mciError;
535  wDeviceId = 0;
536  }
537 
539 
541 
542  return 0;
543 }
HWND hTimeDisplay
Definition: mplay32.c:18
#define MCI_WAIT
Definition: mmsystem.h:730
#define mciSendCommand
Definition: mmsystem.h:2851
WORD wDeviceId
Definition: mplay32.c:26
void UpdateTimeDisplay(HWND hwnd)
Definition: mplay32.c:161
void DisableMenuItems(void)
Definition: mplay32.c:76
DWORD MCIERROR
Definition: mmsystem.h:958
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define MCI_CLOSE
Definition: mmsystem.h:647

◆ CloseMediaFile()

static VOID CloseMediaFile ( HWND  hwnd)
static

Definition at line 875 of file mplay32.c.

Referenced by MainWndProc(), and OpenMediaFile().

876 {
877  StopPlayback(hwnd);
878 
879  if (bIsSingleWindow)
880  SwitchViewMode(hwnd);
881 
882  CloseMciDevice();
883  UpdateWindowCaption(hwnd);
884 }
static VOID SwitchViewMode(HWND hwnd)
Definition: mplay32.c:365
BOOL bIsSingleWindow
Definition: mplay32.c:28
static VOID StopPlayback(HWND hwnd)
Definition: mplay32.c:646
void UpdateWindowCaption(HWND hwnd)
Definition: mplay32.c:96
static MCIERROR CloseMciDevice(VOID)
Definition: mplay32.c:526

◆ DeviceUsesFiles()

static BOOL DeviceUsesFiles ( LPTSTR  lpDeviceName)
static

Definition at line 494 of file mplay32.c.

Referenced by HandleDeviceMenuItem(), and InsertDeviceMenuItem().

495 {
496  MCIERROR mciError;
497  MCI_OPEN_PARMS mciOpen;
498  MCI_GETDEVCAPS_PARMS mciDevCaps;
499  MCI_GENERIC_PARMS mciGeneric;
500 
501  mciOpen.dwCallback = 0;
502  mciOpen.wDeviceID = 0;
503  mciOpen.lpstrDeviceType = lpDeviceName;
504  mciOpen.lpstrElementName = NULL;
505  mciOpen.lpstrAlias = NULL;
506 
507  mciError = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_WAIT, (DWORD_PTR)&mciOpen);
508  if (mciError != 0)
509  return FALSE;
510 
511  mciDevCaps.dwCallback = 0;
512  mciDevCaps.dwReturn = 0;
513  mciDevCaps.dwItem = MCI_GETDEVCAPS_USES_FILES;
514 
515  mciError = mciSendCommand(mciOpen.wDeviceID, MCI_GETDEVCAPS, MCI_WAIT | MCI_GETDEVCAPS_ITEM, (DWORD_PTR)&mciDevCaps);
516  if (mciError != 0)
517  return FALSE;
518 
519  mciGeneric.dwCallback = 0;
520  mciSendCommand(mciOpen.wDeviceID, MCI_CLOSE, MCI_WAIT, (DWORD_PTR)&mciGeneric);
521 
522  return (BOOL)mciDevCaps.dwReturn;
523 }
#define MCI_WAIT
Definition: mmsystem.h:730
#define mciSendCommand
Definition: mmsystem.h:2851
#define MCI_GETDEVCAPS_USES_FILES
Definition: mmsystem.h:763
smooth NULL
Definition: ftsmooth.c:416
#define MCI_OPEN
Definition: mmsystem.h:646
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MCI_OPEN_TYPE
Definition: mmsystem.h:739
MCIDEVICEID wDeviceID
Definition: mmsystem.h:1522
DWORD MCIERROR
Definition: mmsystem.h:958
#define MCI_GETDEVCAPS_ITEM
Definition: mmsystem.h:758
uint32_t DWORD_PTR
Definition: typedefs.h:63
DWORD_PTR dwCallback
Definition: mmsystem.h:1521
DWORD_PTR dwCallback
Definition: mmsystem.h:1517
LPCSTR lpstrDeviceType
Definition: mmsystem.h:1523
#define MCI_CLOSE
Definition: mmsystem.h:647
#define MCI_GETDEVCAPS
Definition: mmsystem.h:654
LPCSTR lpstrElementName
Definition: mmsystem.h:1524

◆ DisableMenuItems()

void DisableMenuItems ( void  )

Definition at line 76 of file mplay32.c.

Referenced by _tWinMain(), and CloseMciDevice().

77 {
81 }
#define MF_BYCOMMAND
Definition: winuser.h:202
#define IDM_DEVPROPS
Definition: resource.h:51
HMENU hMainMenu
Definition: mplay32.c:19
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define IDM_SWITCHVIEW
Definition: resource.h:53
#define IDM_CLOSE_FILE
Definition: resource.h:47
#define MF_GRAYED
Definition: winuser.h:129

◆ EnableMenuItems()

void EnableMenuItems ( HWND  hwnd)

Definition at line 48 of file mplay32.c.

Referenced by OpenMciDevice().

49 {
50  MCIERROR mciError;
51  MCI_GENERIC_PARMS mciGeneric;
52  MCI_DGV_RECT_PARMS mciVideoRect;
53  MCI_DGV_WINDOW_PARMSW mciVideoWindow;
54 
56 
57  mciError = mciSendCommand(wDeviceId, MCI_CONFIGURE, MCI_TEST, (DWORD_PTR)&mciGeneric);
58  if (mciError == 0)
59  {
61  }
62 
63  mciVideoWindow.hWnd = hwnd;
64 
65  mciError = mciSendCommand(wDeviceId, MCI_WINDOW, MCI_DGV_WINDOW_HWND | MCI_TEST, (DWORD_PTR)&mciVideoWindow);
66  if (!mciError)
67  {
69  if (!mciError)
70  {
72  }
73  }
74 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define MF_BYCOMMAND
Definition: winuser.h:202
#define mciSendCommand
Definition: mmsystem.h:2851
#define IDM_DEVPROPS
Definition: resource.h:51
WORD wDeviceId
Definition: mplay32.c:26
#define MCI_WINDOW
Definition: mmsystem.h:665
HMENU hMainMenu
Definition: mplay32.c:19
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MCI_WHERE
Definition: mmsystem.h:667
#define MCI_DGV_WHERE_SOURCE
Definition: digitalv.h:444
#define IDM_SWITCHVIEW
Definition: resource.h:53
#define MCI_DGV_WINDOW_HWND
Definition: digitalv.h:453
#define MCI_CONFIGURE
Definition: digitalv.h:45
#define MCI_TEST
Definition: digitalv.h:32
#define MF_ENABLED
Definition: winuser.h:128
#define IDM_CLOSE_FILE
Definition: resource.h:47
DWORD MCIERROR
Definition: mmsystem.h:958
uint32_t DWORD_PTR
Definition: typedefs.h:63

◆ GetDeviceFriendlyName()

static DWORD GetDeviceFriendlyName ( LPTSTR  lpDeviceName,
LPTSTR  lpFriendlyName,
DWORD  dwFriendlyNameSize 
)
static

Definition at line 464 of file mplay32.c.

Referenced by BuildFileFilterAndDeviceMenu(), and InsertDeviceMenuItem().

465 {
466  MCIERROR mciError;
467  MCI_OPEN_PARMS mciOpen;
468  MCI_INFO_PARMS mciInfo;
469  MCI_GENERIC_PARMS mciGeneric;
470 
471  mciOpen.dwCallback = 0;
472  mciOpen.wDeviceID = 0;
473  mciOpen.lpstrDeviceType = lpDeviceName;
474  mciOpen.lpstrElementName = NULL;
475  mciOpen.lpstrAlias = NULL;
476 
477  mciError = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_WAIT, (DWORD_PTR)&mciOpen);
478  if (mciError != 0)
479  return mciError;
480 
481  mciInfo.dwCallback = 0;
482  mciInfo.lpstrReturn = lpFriendlyName;
483  mciInfo.dwRetSize = dwFriendlyNameSize;
484 
485  mciError = mciSendCommand(mciOpen.wDeviceID, MCI_INFO, MCI_INFO_PRODUCT, (DWORD_PTR)&mciInfo);
486 
487  mciGeneric.dwCallback = 0;
488  mciSendCommand(mciOpen.wDeviceID, MCI_CLOSE, MCI_WAIT, (DWORD_PTR)&mciGeneric);
489 
490  return mciError;
491 }
#define MCI_INFO_PRODUCT
Definition: mmsystem.h:752
#define MCI_WAIT
Definition: mmsystem.h:730
#define mciSendCommand
Definition: mmsystem.h:2851
smooth NULL
Definition: ftsmooth.c:416
#define MCI_OPEN
Definition: mmsystem.h:646
#define MCI_INFO
Definition: mmsystem.h:653
#define MCI_OPEN_TYPE
Definition: mmsystem.h:739
MCIDEVICEID wDeviceID
Definition: mmsystem.h:1522
DWORD MCIERROR
Definition: mmsystem.h:958
uint32_t DWORD_PTR
Definition: typedefs.h:63
DWORD_PTR dwCallback
Definition: mmsystem.h:1521
DWORD_PTR dwCallback
Definition: mmsystem.h:1517
LPCSTR lpstrDeviceType
Definition: mmsystem.h:1523
#define MCI_CLOSE
Definition: mmsystem.h:647
LPCSTR lpstrElementName
Definition: mmsystem.h:1524
DWORD_PTR dwCallback
Definition: mmsystem.h:1573

◆ GetDeviceMode()

static DWORD GetDeviceMode ( HWND  hwnd)
static

Definition at line 629 of file mplay32.c.

Referenced by TogglePlaybackState(), and UpdateWindowCaption().

630 {
631  MCIERROR mciError;
632  MCI_STATUS_PARMS mciStatus;
633 
634  mciStatus.dwItem = MCI_STATUS_MODE;
636  if (mciError != 0)
637  {
638  ShowMCIError(hwnd, mciError);
639  return MCI_MODE_NOT_READY;
640  }
641 
642  return mciStatus.dwReturn;
643 }
#define MCI_STATUS_ITEM
Definition: mmsystem.h:742
#define MCI_WAIT
Definition: mmsystem.h:730
#define mciSendCommand
Definition: mmsystem.h:2851
static VOID ShowMCIError(HWND hwnd, MCIERROR mciError)
Definition: mplay32.c:282
WORD wDeviceId
Definition: mplay32.c:26
DWORD_PTR dwReturn
Definition: mmsystem.h:1567
#define MCI_STATUS
Definition: mmsystem.h:662
#define MCI_STATUS_MODE
Definition: mmsystem.h:747
DWORD MCIERROR
Definition: mmsystem.h:958
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define MCI_MODE_NOT_READY
Definition: mmsystem.h:694

◆ GetDeviceName()

static DWORD GetDeviceName ( DWORD  dwDeviceIndex,
LPTSTR  lpDeviceName,
DWORD  dwDeviceNameSize 
)
static

Definition at line 450 of file mplay32.c.

Referenced by BuildFileFilterAndDeviceMenu(), HandleDeviceMenuItem(), and InsertDeviceMenuItem().

451 {
452  MCI_SYSINFO_PARMS mciSysInfo;
453 
454  mciSysInfo.dwCallback = 0;
455  mciSysInfo.lpstrReturn = lpDeviceName;
456  mciSysInfo.dwRetSize = dwDeviceNameSize;
457  mciSysInfo.dwNumber = dwDeviceIndex;
459 
461 }
#define mciSendCommand
Definition: mmsystem.h:2851
DWORD_PTR dwCallback
Definition: mmsystem.h:1591
#define MCI_ALL_DEVICE_ID
Definition: mmsystem.h:679
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define MCI_DEVTYPE_WAVEFORM_AUDIO
Definition: mmsystem.h:689
#define MCI_SYSINFO_NAME
Definition: mmsystem.h:770
#define MCI_SYSINFO
Definition: mmsystem.h:659

◆ GetNumDevices()

static DWORD GetNumDevices ( VOID  )
static

Definition at line 433 of file mplay32.c.

Referenced by BuildFileFilterAndDeviceMenu().

434 {
435  MCI_SYSINFO_PARMS mciSysInfo;
436  DWORD dwNumDevices = 0;
437 
438  mciSysInfo.dwCallback = 0;
439  mciSysInfo.lpstrReturn = (LPTSTR)&dwNumDevices;
440  mciSysInfo.dwRetSize = sizeof(dwNumDevices);
441  mciSysInfo.dwNumber = 0;
442  mciSysInfo.wDeviceType = MCI_ALL_DEVICE_ID;
443 
445 
446  return *(DWORD*)mciSysInfo.lpstrReturn;
447 }
#define mciSendCommand
Definition: mmsystem.h:2851
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define MCI_SYSINFO_QUANTITY
Definition: mmsystem.h:768
DWORD_PTR dwCallback
Definition: mmsystem.h:1591
#define MCI_ALL_DEVICE_ID
Definition: mmsystem.h:679
unsigned long DWORD
Definition: ntddk_ex.h:95
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define MCI_SYSINFO
Definition: mmsystem.h:659

◆ HandleDeviceMenuItem()

static VOID HandleDeviceMenuItem ( HWND  hwnd,
UINT  uItem 
)
static

Definition at line 1173 of file mplay32.c.

Referenced by MainWndProc().

1174 {
1175  MENUITEMINFO lpmii;
1177  MCIERROR mciError;
1178 
1179  ZeroMemory(&lpmii, sizeof(MENUITEMINFO));
1180  lpmii.cbSize = sizeof(lpmii);
1181  lpmii.fMask = MIIM_DATA;
1182  GetMenuItemInfo(hMainMenu, uItem, FALSE, &lpmii);
1183 
1184  mciError = GetDeviceName(lpmii.dwItemData, szDeviceName, sizeof(szDeviceName));
1185  if (mciError)
1186  {
1187  ShowMCIError(hwnd, mciError);
1188  return;
1189  }
1190 
1191  if (DeviceUsesFiles(szDeviceName))
1192  {
1193  OpenFileDialog(hwnd, uItem - IDM_DEVICE_FIRST + 1, szDeviceName);
1194  return;
1195  }
1196 
1197  mciError = OpenMciDevice(hwnd, szDeviceName, NULL);
1198  if (mciError)
1199  {
1200  ShowMCIError(hwnd, mciError);
1201  }
1202 
1203  return;
1204 }
static DWORD GetDeviceName(DWORD dwDeviceIndex, LPTSTR lpDeviceName, DWORD dwDeviceNameSize)
Definition: mplay32.c:450
ULONG_PTR dwItemData
Definition: winuser.h:3192
static MCIERROR OpenMciDevice(HWND hwnd, LPTSTR lpType, LPTSTR lpFileName)
Definition: mplay32.c:546
static VOID ShowMCIError(HWND hwnd, MCIERROR mciError)
Definition: mplay32.c:282
#define ZeroMemory
Definition: winbase.h:1635
HMENU hMainMenu
Definition: mplay32.c:19
smooth NULL
Definition: ftsmooth.c:416
#define GetMenuItemInfo
Definition: winuser.h:5654
char TCHAR
Definition: xmlstorage.h:189
static BOOL DeviceUsesFiles(LPTSTR lpDeviceName)
Definition: mplay32.c:494
DWORD MCIERROR
Definition: mmsystem.h:958
static const WCHAR szDeviceName[]
Definition: provider.c:53
#define MAX_MCISTR
Definition: mplay32.c:13
#define IDM_DEVICE_FIRST
Definition: resource.h:56
#define MIIM_DATA
Definition: winuser.h:721
static VOID OpenFileDialog(HWND hwnd, DWORD dwFilterIndex, LPTSTR lpType)
Definition: mplay32.c:1142

◆ InitControls()

static VOID InitControls ( HWND  hwnd)
static

Definition at line 297 of file mplay32.c.

Referenced by _tWinMain(), DllMain(), Initialize(), MainWndProc(), CMainWindow::ProcessWindowMessage(), and wWinMain().

298 {
299  INT NumButtons = ARRAYSIZE(Buttons);
300 
302 
303  /* Create trackbar */
306  NULL,
308  0,
309  0,
310  340,
311  20,
312  hwnd,
313  NULL,
314  hInstance,
315  NULL);
316  if (!hTrackBar)
317  {
318  ShowLastWin32Error(hwnd);
319  return;
320  }
321 
322  /* Create toolbar */
325  NULL,
328  0,
329  40,
330  340,
331  30,
332  hwnd,
333  NULL,
334  hInstance,
335  NULL);
336  if (!hToolBar)
337  {
338  ShowLastWin32Error(hwnd);
339  return;
340  }
341 
343  L"STATIC",
344  NULL,
346  195,
347  4,
348  135,
349  18,
350  hToolBar,
351  NULL,
352  hInstance,
353  NULL);
354  if (!hTimeDisplay)
355  {
356  ShowLastWin32Error(hwnd);
357  return;
358  }
359 
360  SetImageList(hwnd);
362 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
HWND hTimeDisplay
Definition: mplay32.c:18
HWND hTrackBar
Definition: mplay32.c:16
#define TBS_ENABLESELRANGE
Definition: commctrl.h:1994
#define TRACKBAR_CLASS
Definition: commctrl.h:1983
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
HINSTANCE hInstance
Definition: mplay32.c:15
HWND hToolBar
Definition: mplay32.c:17
#define WS_CHILD
Definition: pedump.c:617
int32_t INT
Definition: typedefs.h:56
static VOID ShowLastWin32Error(HWND hwnd)
Definition: mplay32.c:207
LONG_PTR LPARAM
Definition: windef.h:208
#define CreateWindowEx
Definition: winuser.h:5621
#define TOOLBARCLASSNAME
Definition: commctrl.h:916
smooth NULL
Definition: ftsmooth.c:416
#define CCS_BOTTOM
Definition: commctrl.h:2214
static const TBBUTTON Buttons[]
Definition: mplay32.c:35
#define SS_CENTER
Definition: pedump.c:693
#define TBSTYLE_TOOLTIPS
Definition: commctrl.h:959
static const WCHAR L[]
Definition: oid.c:1087
#define TB_ADDBUTTONS
Definition: commctrl.h:1241
static VOID SetImageList(HWND hwnd)
Definition: mplay32.c:232
#define WS_TABSTOP
Definition: pedump.c:634
#define SS_SUNKEN
Definition: winuser.h:358
#define SendMessage
Definition: winuser.h:5709
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:863
#define WS_VISIBLE
Definition: pedump.c:620
#define TBSTYLE_FLAT
Definition: commctrl.h:962

◆ InsertDeviceMenuItem()

static DWORD InsertDeviceMenuItem ( HMENU  hMenu,
UINT  uItem,
BOOL  fByPosition,
UINT  uItemID,
DWORD  dwDeviceIndex 
)
static

Definition at line 908 of file mplay32.c.

Referenced by BuildFileFilterAndDeviceMenu().

909 {
910  MENUITEMINFO lpmii;
911  MCIERROR mciError;
913  TCHAR szFriendlyName[MAX_MCISTR];
914 
915  mciError = GetDeviceName(dwDeviceIndex, szDeviceName, sizeof(szDeviceName));
916  if (mciError)
917  {
918  return mciError;
919  }
920 
921  mciError = GetDeviceFriendlyName(szDeviceName, szFriendlyName, sizeof(szFriendlyName));
922  if (mciError)
923  {
924  return mciError;
925  }
926 
927  if (DeviceUsesFiles(szDeviceName))
928  {
929  StringCbCat(szFriendlyName, sizeof(szFriendlyName), _T("..."));
930  }
931 
932  ZeroMemory(&lpmii, sizeof(MENUITEMINFO));
933  lpmii.cbSize = sizeof(lpmii);
934  lpmii.fMask = MIIM_DATA | MIIM_TYPE | MIIM_ID;
935  lpmii.wID = uItemID;
936  lpmii.fType = MF_STRING;
937  lpmii.dwTypeData = szFriendlyName;
938  lpmii.dwItemData = dwDeviceIndex;
939  InsertMenuItem(hMenu, uItem, fByPosition, &lpmii);
940 
941  return 0;
942 }
static DWORD GetDeviceName(DWORD dwDeviceIndex, LPTSTR lpDeviceName, DWORD dwDeviceNameSize)
Definition: mplay32.c:450
ULONG_PTR dwItemData
Definition: winuser.h:3192
#define MF_STRING
Definition: winuser.h:138
#define ZeroMemory
Definition: winbase.h:1635
#define MIIM_ID
Definition: winuser.h:717
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define StringCbCat
Definition: strsafe.h:334
static BOOL DeviceUsesFiles(LPTSTR lpDeviceName)
Definition: mplay32.c:494
DWORD MCIERROR
Definition: mmsystem.h:958
#define MIIM_TYPE
Definition: winuser.h:720
static const WCHAR szDeviceName[]
Definition: provider.c:53
static DWORD GetDeviceFriendlyName(LPTSTR lpDeviceName, LPTSTR lpFriendlyName, DWORD dwFriendlyNameSize)
Definition: mplay32.c:464
#define MAX_MCISTR
Definition: mplay32.c:13
#define MIIM_DATA
Definition: winuser.h:721
LPSTR dwTypeData
Definition: winuser.h:3193
#define InsertMenuItem
Definition: winuser.h:5670

◆ MainWndProc()

LRESULT CALLBACK MainWndProc ( HWND  hwnd,
UINT  Message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1207 of file mplay32.c.

Referenced by _tWinMain().

1208 {
1209  switch (Message)
1210  {
1211  case WM_CREATE:
1212  {
1213  InitControls(hwnd);
1214  hMainMenu = GetMenu(hwnd);
1215  break;
1216  }
1217 
1218  case WM_DROPFILES:
1219  {
1220  HDROP drophandle;
1221  TCHAR droppedfile[MAX_PATH];
1222 
1223  drophandle = (HDROP)wParam;
1224  DragQueryFile(drophandle, 0, droppedfile, ARRAYSIZE(droppedfile));
1225  DragFinish(drophandle);
1226  OpenMediaFile(hwnd, droppedfile, NULL);
1227  break;
1228  }
1229 
1230  case MM_MCINOTIFY:
1231  {
1233  {
1234  StopPlayback(hwnd);
1235  if (bRepeat)
1236  {
1237  StartPlayback(hwnd);
1238  }
1239  }
1240  break;
1241  }
1242 
1243  case WM_NOTIFY:
1244  {
1245  LPNMHDR pnmhdr = (LPNMHDR)lParam;
1246 
1247  switch (pnmhdr->code)
1248  {
1249  case TTN_GETDISPINFO:
1250  {
1252  UINT idButton = (UINT)lpttt->hdr.idFrom;
1253 
1254  switch (idButton)
1255  {
1256  case IDC_PLAY:
1257  lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_PLAY);
1258  break;
1259  case IDC_STOP:
1260  lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_STOP);
1261  break;
1262  case IDC_EJECT:
1263  lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_EJECT);
1264  break;
1265  case IDC_BACKWARD:
1266  lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_BACKWARD);
1267  break;
1268  case IDC_SEEKBACK:
1269  lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_SEEKBACK);
1270  break;
1271  case IDC_SEEKFORW:
1272  lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_SEEKFORW);
1273  break;
1274  case IDC_FORWARD:
1275  lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_FORWARD);
1276  break;
1277  case IDC_PAUSE:
1278  lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_PAUSE);
1279  break;
1280  }
1281  break;
1282  }
1283  }
1284  }
1285  break;
1286 
1287  case WM_SIZING:
1288  {
1289  LPRECT pRect = (LPRECT)lParam;
1290 
1291  if (!bIsSingleWindow)
1292  {
1293  if (pRect->right - pRect->left < MAIN_WINDOW_MIN_WIDTH)
1294  pRect->right = pRect->left + MAIN_WINDOW_MIN_WIDTH;
1295 
1296  if (pRect->bottom - pRect->top != MAIN_WINDOW_HEIGHT)
1297  pRect->bottom = pRect->top + MAIN_WINDOW_HEIGHT;
1298  }
1299  return TRUE;
1300  }
1301 
1302  case WM_SIZE:
1303  {
1304  RECT Rect;
1305 
1306  if (hToolBar && hTrackBar)
1307  {
1310  MoveWindow(hTimeDisplay, LOWORD(lParam) - 140, 4, 135, 18, TRUE);
1311 
1312  if (!bIsSingleWindow)
1313  {
1315  MoveWindow(hTrackBar, 0, 0, LOWORD(lParam), HIWORD(lParam) - Size, TRUE);
1316  }
1317  else
1318  {
1319  RECT ToolbarRect;
1320  MCI_DGV_PUT_PARMS mciPut;
1321 
1322  MoveWindow(hTrackBar, 180, 0, LOWORD(lParam) - 322, 25, TRUE);
1323 
1324  GetClientRect(hwnd, &Rect);
1325  GetClientRect(hToolBar, &ToolbarRect);
1326 
1327  mciPut.rc.top = 0;
1328  mciPut.rc.left = 0;
1329  mciPut.rc.right = Rect.right;
1330  mciPut.rc.bottom = Rect.bottom - (ToolbarRect.bottom - ToolbarRect.top) - 2;
1331 
1333  }
1334  }
1335  return 0L;
1336  }
1337 
1338  case WM_HSCROLL:
1339  {
1340  if (hTrackBar == (HWND)lParam)
1341  {
1342  if (wDeviceId)
1343  {
1344  DWORD dwNewPos = (DWORD)SendMessage(hTrackBar, TBM_GETPOS, 0, 0);
1345  SeekPlayback(hwnd, dwNewPos);
1346  }
1347  else
1348  {
1350  }
1351  }
1352  }
1353  break;
1354 
1355  case WM_NCLBUTTONDBLCLK:
1356  {
1357  if (wParam == HTCAPTION)
1358  {
1359  SwitchViewMode(hwnd);
1360  }
1361  }
1362  break;
1363 
1364  case WM_COMMAND:
1365  {
1366  if (LOWORD(wParam) >= IDM_DEVICE_FIRST)
1367  {
1369  break;
1370  }
1371 
1372  switch (LOWORD(wParam))
1373  {
1374  case IDC_PLAY:
1375  case IDC_PAUSE:
1376  {
1377  if (wDeviceId)
1378  TogglePlaybackState(hwnd);
1379  else
1380  OpenFileDialog(hwnd, 1, NULL);
1381 
1382  break;
1383  }
1384 
1385  case IDC_STOP:
1386  StopPlayback(hwnd);
1387  break;
1388 
1389  case IDC_EJECT:
1390  break;
1391 
1392  case IDC_BACKWARD:
1393  break;
1394 
1395  case IDC_SEEKBACK:
1396  SeekBackPlayback(hwnd);
1397  break;
1398 
1399  case IDC_SEEKFORW:
1400  SeekForwPlayback(hwnd);
1401  break;
1402 
1403  case IDC_FORWARD:
1404  break;
1405 
1406  case IDM_OPEN_FILE:
1407  OpenFileDialog(hwnd, 1, NULL);
1408  return 0;
1409 
1410  case IDM_CLOSE_FILE:
1411  CloseMediaFile(hwnd);
1412  break;
1413 
1414  case IDM_REPEAT:
1415  {
1416  if (!bRepeat)
1417  {
1419  bRepeat = TRUE;
1420  }
1421  else
1422  {
1424  bRepeat = FALSE;
1425  }
1426  break;
1427  }
1428 
1429  case IDM_SWITCHVIEW:
1430  SwitchViewMode(hwnd);
1431  break;
1432 
1433  case IDM_DEVPROPS:
1434  ShowDeviceProperties(hwnd);
1435  break;
1436 
1437  case IDM_VOLUMECTL:
1438  ShellExecute(hwnd, NULL, _T("SNDVOL32.EXE"), NULL, NULL, SW_SHOWNORMAL);
1439  break;
1440 
1441  case IDM_ABOUT:
1442  {
1444  ShellAbout(hwnd, szAppTitle, 0, mplayIcon);
1445  DeleteObject(mplayIcon);
1446  break;
1447  }
1448 
1449  case IDM_EXIT:
1450  PostMessage(hwnd, WM_CLOSE, 0, 0);
1451  return 0;
1452  }
1453  break;
1454  }
1455 
1456  case WM_DESTROY:
1457  CloseMediaFile(hwnd);
1458  PostQuitMessage(0);
1459  return 0;
1460  }
1461 
1462  return DefWindowProc(hwnd, Message, wParam, lParam);
1463 }
HWND hTimeDisplay
Definition: mplay32.c:18
#define IDC_SEEKBACK
Definition: resource.h:72
#define MCI_DGV_PUT_DESTINATION
Definition: digitalv.h:234
#define MAKEINTRESOURCE
Definition: winuser.h:591
static HICON
Definition: imagelist.c:84
#define IDS_TOOLTIP_SEEKFORW
Definition: resource.h:23
#define TRUE
Definition: types.h:120
#define IDC_BACKWARD
Definition: resource.h:71
#define IDS_TOOLTIP_STOP
Definition: resource.h:19
#define MF_BYCOMMAND
Definition: winuser.h:202
HWND hTrackBar
Definition: mplay32.c:16
#define IDM_ABOUT
Definition: resource.h:29
#define MCI_WAIT
Definition: mmsystem.h:730
static VOID TogglePlaybackState(HWND hwnd)
Definition: mplay32.c:801
#define DWORD
Definition: msvc.h:34
#define mciSendCommand
Definition: mmsystem.h:2851
static VOID HandleDeviceMenuItem(HWND hwnd, UINT uItem)
Definition: mplay32.c:1173
#define IDC_SEEKFORW
Definition: resource.h:73
LONG top
Definition: windef.h:297
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HINSTANCE hInstance
Definition: mplay32.c:15
#define TBM_SETPOS
Definition: commctrl.h:2006
#define IDM_DEVPROPS
Definition: resource.h:51
HWND hToolBar
Definition: mplay32.c:17
static VOID StartPlayback(HWND hwnd)
Definition: mplay32.c:767
LONG left
Definition: windef.h:296
#define IDC_PAUSE
Definition: resource.h:75
LONG right
Definition: windef.h:298
WPARAM wParam
Definition: combotst.c:138
BOOL bRepeat
Definition: mplay32.c:27
static VOID InitControls(HWND hwnd)
Definition: mplay32.c:297
#define TB_GETITEMRECT
Definition: commctrl.h:1103
struct tagNMHDR * LPNMHDR
WORD wDeviceId
Definition: mplay32.c:26
UINT code
Definition: winuser.h:3112
#define MAIN_WINDOW_HEIGHT
Definition: mplay32.c:11
#define IDM_REPEAT
Definition: resource.h:52
HMENU hMainMenu
Definition: mplay32.c:19
#define MAIN_WINDOW_MIN_WIDTH
Definition: mplay32.c:12
static VOID SwitchViewMode(HWND hwnd)
Definition: mplay32.c:365
#define TB_AUTOSIZE
Definition: commctrl.h:1107
LONG_PTR LPARAM
Definition: windef.h:208
#define TBM_GETPOS
Definition: commctrl.h:2001
#define IDS_TOOLTIP_EJECT
Definition: resource.h:20
#define ShellExecute
Definition: shellapi.h:679
#define WM_DROPFILES
Definition: winuser.h:1801
#define TTN_GETDISPINFO
Definition: commctrl.h:1848
#define IDC_STOP
Definition: resource.h:69
#define WM_SIZING
Definition: winuser.h:1783
smooth NULL
Definition: ftsmooth.c:416
switch(r->id)
Definition: btrfs.c:2691
static VOID OpenMediaFile(HWND hwnd, LPTSTR lpFileName, LPTSTR lpType)
Definition: mplay32.c:887
#define IDM_SWITCHVIEW
Definition: resource.h:53
BOOL bIsSingleWindow
Definition: mplay32.c:28
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
#define PostMessage
Definition: winuser.h:5698
#define MF_CHECKED
Definition: winuser.h:132
#define LPTOOLTIPTEXT
Definition: commctrl.h:1860
#define LPRECT
Definition: msvc.h:30
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define IDS_TOOLTIP_SEEKBACK
Definition: resource.h:22
#define WM_SIZE
Definition: winuser.h:1593
#define IDC_EJECT
Definition: resource.h:70
#define IDM_OPEN_FILE
Definition: resource.h:46
static VOID SeekBackPlayback(HWND hwnd)
Definition: mplay32.c:705
#define WM_CLOSE
Definition: winuser.h:1603
#define MAX_PATH
Definition: compat.h:26
TCHAR szAppTitle[256]
Definition: mplay32.c:21
unsigned int UINT
Definition: ndis.h:50
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
static VOID CloseMediaFile(HWND hwnd)
Definition: mplay32.c:875
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define ShellAbout
Definition: shellapi.h:678
#define IDM_CLOSE_FILE
Definition: resource.h:47
CHAR Message[80]
Definition: alive.c:5
#define MCI_NOTIFY_SUCCESSFUL
Definition: mmsystem.h:725
static const WCHAR L[]
Definition: oid.c:1087
#define IDI_MAIN
Definition: resource.h:4
#define IDS_TOOLTIP_PLAY
Definition: resource.h:18
#define IDC_FORWARD
Definition: resource.h:74
#define IDS_TOOLTIP_PAUSE
Definition: resource.h:25
#define WM_COMMAND
Definition: winuser.h:1716
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define MF_UNCHECKED
Definition: winuser.h:204
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
#define HTCAPTION
Definition: winuser.h:2430
static VOID StopPlayback(HWND hwnd)
Definition: mplay32.c:646
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define SW_SHOWNORMAL
Definition: winuser.h:764
static VOID SeekForwPlayback(HWND hwnd)
Definition: mplay32.c:728
#define MCI_PUT
Definition: mmsystem.h:666
#define MM_MCINOTIFY
Definition: mmsystem.h:55
#define IDC_PLAY
Definition: resource.h:68
static VOID SeekPlayback(HWND hwnd, DWORD dwNewPos)
Definition: mplay32.c:681
#define WM_HSCROLL
Definition: winuser.h:1719
#define IDM_EXIT
Definition: resource.h:27
#define DragQueryFile
Definition: shellapi.h:672
#define IDM_VOLUMECTL
Definition: resource.h:50
#define IDS_TOOLTIP_FORWARD
Definition: resource.h:24
#define SendMessage
Definition: winuser.h:5709
void WINAPI DragFinish(HDROP h)
Definition: shellole.c:543
#define WM_CREATE
Definition: winuser.h:1590
#define IDM_DEVICE_FIRST
Definition: resource.h:56
#define HIWORD(l)
Definition: typedefs.h:246
LONG bottom
Definition: windef.h:299
#define MCI_DGV_RECT
Definition: digitalv.h:232
#define IDS_TOOLTIP_BACKWARD
Definition: resource.h:21
#define SM_CYMENU
Definition: winuser.h:966
#define LoadIcon
Definition: winuser.h:5679
static VOID ShowDeviceProperties(HWND hwnd)
Definition: mplay32.c:862
#define UINT
Definition: msvc.h:27
HMENU WINAPI GetMenu(_In_ HWND)
static VOID OpenFileDialog(HWND hwnd, DWORD dwFilterIndex, LPTSTR lpType)
Definition: mplay32.c:1142
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_NOTIFY
Definition: richedit.h:61
struct Rect Rect
#define WM_NCLBUTTONDBLCLK
Definition: winuser.h:1676

◆ OpenFileDialog()

static VOID OpenFileDialog ( HWND  hwnd,
DWORD  dwFilterIndex,
LPTSTR  lpType 
)
static

Definition at line 1142 of file mplay32.c.

Referenced by HandleDeviceMenuItem(), and MainWndProc().

1143 {
1144  OPENFILENAME OpenFileName;
1145  TCHAR szFile[MAX_PATH + 1] = _T("");
1146  TCHAR szCurrentDir[MAX_PATH];
1147 
1148  ZeroMemory(&OpenFileName, sizeof(OpenFileName));
1149 
1150  if (!GetCurrentDirectory(ARRAYSIZE(szCurrentDir), szCurrentDir))
1151  {
1152  StringCbCopy(szCurrentDir, sizeof(szCurrentDir), _T("c:\\"));
1153  }
1154 
1155  OpenFileName.lStructSize = sizeof(OpenFileName);
1156  OpenFileName.hwndOwner = hwnd;
1157  OpenFileName.hInstance = hInstance;
1158  OpenFileName.lpstrFilter = szFilter;
1159  OpenFileName.lpstrFile = szFile;
1160  OpenFileName.nMaxFile = ARRAYSIZE(szFile);
1161  OpenFileName.lpstrInitialDir = szCurrentDir;
1163  OpenFileName.lpstrDefExt = _T("\0");
1164  OpenFileName.nFilterIndex = dwFilterIndex;
1165 
1166  if (!GetOpenFileName(&OpenFileName))
1167  return;
1168 
1169  OpenMediaFile(hwnd, OpenFileName.lpstrFile, lpType);
1170 }
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HWND hwndOwner
Definition: commdlg.h:330
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define ZeroMemory
Definition: winbase.h:1635
HINSTANCE hInstance
Definition: mplay32.c:15
LPCSTR lpstrDefExt
Definition: commdlg.h:345
#define GetOpenFileName
Definition: commdlg.h:665
DWORD nMaxFile
Definition: commdlg.h:337
#define GetCurrentDirectory
Definition: winbase.h:3619
LPTSTR szFilter
Definition: mplay32.c:24
HINSTANCE hInstance
Definition: commdlg.h:331
static VOID OpenMediaFile(HWND hwnd, LPTSTR lpFileName, LPTSTR lpType)
Definition: mplay32.c:887
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
LPCSTR lpstrInitialDir
Definition: commdlg.h:340
#define MAX_PATH
Definition: compat.h:26
DWORD lStructSize
Definition: commdlg.h:329
#define StringCbCopy
Definition: strsafe.h:155
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define OFN_SHAREAWARE
Definition: commdlg.h:119
LPSTR lpstrFile
Definition: commdlg.h:336
LPCSTR lpstrFilter
Definition: commdlg.h:332
DWORD nFilterIndex
Definition: commdlg.h:335
DWORD Flags
Definition: commdlg.h:342

◆ OpenMciDevice()

static MCIERROR OpenMciDevice ( HWND  hwnd,
LPTSTR  lpType,
LPTSTR  lpFileName 
)
static

Definition at line 546 of file mplay32.c.

Referenced by HandleDeviceMenuItem(), and OpenMediaFile().

547 {
548  MCIERROR mciError;
549  MCI_STATUS_PARMS mciStatus;
550  MCI_OPEN_PARMS mciOpen;
552  LPTSTR lpStr;
553 
554  if (wDeviceId)
555  CloseMciDevice();
556 
557  mciOpen.lpstrDeviceType = lpType;
558  mciOpen.lpstrElementName = lpFileName;
559  mciOpen.dwCallback = 0;
560  mciOpen.wDeviceID = 0;
561  mciOpen.lpstrAlias = NULL;
562 
563  if (lpType)
564  dwFlags |= MCI_OPEN_TYPE;
565 
566  if (lpFileName)
567  dwFlags |= MCI_OPEN_ELEMENT;
568 
569  mciError = mciSendCommand(0, MCI_OPEN, dwFlags, (DWORD_PTR)&mciOpen);
570  if (mciError != 0)
571  return mciError;
572 
573  mciStatus.dwItem = MCI_STATUS_LENGTH;
574 
575  mciError = mciSendCommand(mciOpen.wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (DWORD_PTR)&mciStatus);
576  if (mciError != 0)
577  return mciError;
578 
584 
585  if (mciStatus.dwReturn < 10000)
586  {
588  }
589  else if (mciStatus.dwReturn < 100000)
590  {
592  }
593  else if (mciStatus.dwReturn < 1000000)
594  {
596  }
597  else
598  {
600  }
601 
602  MaxFilePos = mciStatus.dwReturn;
603  wDeviceId = mciOpen.wDeviceID;
604 
605  /* NOTE: Everything above this line may be done instead in OpenMediaFile() */
606 
607  if (lpFileName)
608  {
609  lpStr = _tcsrchr(lpFileName, _T('\\'));
610  if (lpStr) // Get only the file name (skip the last path separator)
611  lpStr++;
612  else
613  lpStr = lpFileName;
614  }
615  else
616  lpStr = lpType;
617 
618  StringCbCopy(szCurrentFile, sizeof(szCurrentFile), lpStr);
619 
620  EnableMenuItems(hwnd);
621 
623  UpdateWindowCaption(hwnd);
624 
625  return 0;
626 }
HWND hTimeDisplay
Definition: mplay32.c:18
#define TRUE
Definition: types.h:120
HWND hTrackBar
Definition: mplay32.c:16
#define MCI_STATUS_ITEM
Definition: mmsystem.h:742
#define MCI_WAIT
Definition: mmsystem.h:730
UINT MaxFilePos
Definition: mplay32.c:29
#define mciSendCommand
Definition: mmsystem.h:2851
#define TBM_SETPOS
Definition: commctrl.h:2006
CHAR * LPTSTR
Definition: xmlstorage.h:192
WORD wDeviceId
Definition: mplay32.c:26
UINT_PTR WPARAM
Definition: windef.h:207
#define TBM_SETRANGEMIN
Definition: commctrl.h:2008
DWORD_PTR dwReturn
Definition: mmsystem.h:1567
void UpdateTimeDisplay(HWND hwnd)
Definition: mplay32.c:161
#define TBM_SETRANGEMAX
Definition: commctrl.h:2009
LONG_PTR LPARAM
Definition: windef.h:208
#define TBM_SETPAGESIZE
Definition: commctrl.h:2021
smooth NULL
Definition: ftsmooth.c:416
#define MCI_OPEN
Definition: mmsystem.h:646
#define TBM_SETTICFREQ
Definition: commctrl.h:2020
TCHAR szCurrentFile[MAX_PATH]
Definition: mplay32.c:23
void EnableMenuItems(HWND hwnd)
Definition: mplay32.c:48
#define MCI_STATUS
Definition: mmsystem.h:662
#define _T(x)
Definition: vfdio.h:22
#define MCI_STATUS_LENGTH
Definition: mmsystem.h:744
#define MCI_OPEN_TYPE
Definition: mmsystem.h:739
unsigned long DWORD
Definition: ntddk_ex.h:95
MCIDEVICEID wDeviceID
Definition: mmsystem.h:1522
DWORD MCIERROR
Definition: mmsystem.h:958
#define StringCbCopy
Definition: strsafe.h:155
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
uint32_t DWORD_PTR
Definition: typedefs.h:63
DWORD_PTR dwCallback
Definition: mmsystem.h:1521
LPCSTR lpstrDeviceType
Definition: mmsystem.h:1523
#define MCI_OPEN_ELEMENT
Definition: mmsystem.h:735
#define SendMessage
Definition: winuser.h:5709
_TCHAR * _tcsrchr(const _TCHAR *s, _XINT c)
Definition: tcsrchr.h:4
LPCSTR lpstrElementName
Definition: mmsystem.h:1524
_In_ LPCSTR lpFileName
Definition: winbase.h:3011
void UpdateWindowCaption(HWND hwnd)
Definition: mplay32.c:96
static MCIERROR CloseMciDevice(VOID)
Definition: mplay32.c:526
#define TBM_SETLINESIZE
Definition: commctrl.h:2023

◆ OpenMediaFile()

static VOID OpenMediaFile ( HWND  hwnd,
LPTSTR  lpFileName,
LPTSTR  lpType 
)
static

Definition at line 887 of file mplay32.c.

Referenced by _tWinMain(), MainWndProc(), and OpenFileDialog().

888 {
889  MCIERROR mciError;
890 
892  return;
893 
894  if (wDeviceId)
895  CloseMediaFile(hwnd);
896 
897  mciError = OpenMciDevice(hwnd, lpType, lpFileName);
898  if (mciError != 0)
899  {
900  ShowMCIError(hwnd, mciError);
901  return;
902  }
903 
904  StartPlayback(hwnd);
905 }
static MCIERROR OpenMciDevice(HWND hwnd, LPTSTR lpType, LPTSTR lpFileName)
Definition: mplay32.c:546
static VOID ShowMCIError(HWND hwnd, MCIERROR mciError)
Definition: mplay32.c:282
static VOID StartPlayback(HWND hwnd)
Definition: mplay32.c:767
WORD wDeviceId
Definition: mplay32.c:26
static VOID CloseMediaFile(HWND hwnd)
Definition: mplay32.c:875
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
DWORD MCIERROR
Definition: mmsystem.h:958
#define GetFileAttributes
Definition: winbase.h:3629
_In_ LPCSTR lpFileName
Definition: winbase.h:3011

◆ PlayTimerProc()

VOID CALLBACK PlayTimerProc ( HWND  hwnd,
UINT  uMsg,
UINT_PTR  idEvent,
DWORD  dwTime 
)

Definition at line 751 of file mplay32.c.

Referenced by StartPlayback().

752 {
753  MCI_STATUS_PARMS mciStatus;
754  DWORD dwPos;
755 
756  if (wDeviceId == 0) KillTimer(hwnd, IDT_PLAYTIMER);
757 
758  mciStatus.dwItem = MCI_STATUS_POSITION;
760  dwPos = mciStatus.dwReturn;
761 
764 }
HWND hTimeDisplay
Definition: mplay32.c:18
#define TRUE
Definition: types.h:120
HWND hTrackBar
Definition: mplay32.c:16
#define MCI_STATUS_ITEM
Definition: mmsystem.h:742
#define mciSendCommand
Definition: mmsystem.h:2851
#define TBM_SETPOS
Definition: commctrl.h:2006
#define MCI_STATUS_POSITION
Definition: mmsystem.h:745
WORD wDeviceId
Definition: mplay32.c:26
UINT_PTR WPARAM
Definition: windef.h:207
DWORD_PTR dwReturn
Definition: mmsystem.h:1567
void UpdateTimeDisplay(HWND hwnd)
Definition: mplay32.c:161
LONG_PTR LPARAM
Definition: windef.h:208
#define IDT_PLAYTIMER
Definition: mplay32.c:9
#define MCI_STATUS
Definition: mmsystem.h:662
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define SendMessage
Definition: winuser.h:5709

◆ ResizeClientArea()

void ResizeClientArea ( HWND  hwnd,
int  nWidth,
int  nHeight 
)

Definition at line 83 of file mplay32.c.

Referenced by SwitchViewMode().

84 {
85  RECT rcClientRect;
86  RECT rcWindowRect;
87  POINT ptDifference;
88 
89  GetClientRect(hwnd, &rcClientRect);
90  GetWindowRect(hwnd, &rcWindowRect);
91  ptDifference.x = (rcWindowRect.right - rcWindowRect.left) - rcClientRect.right;
92  ptDifference.y = (rcWindowRect.bottom - rcWindowRect.top) - rcClientRect.bottom;
93  MoveWindow(hwnd, rcWindowRect.left, rcWindowRect.top, nWidth + ptDifference.x, nHeight + ptDifference.y, TRUE);
94 }
#define TRUE
Definition: types.h:120
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG top
Definition: windef.h:297
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
LONG bottom
Definition: windef.h:299
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)

◆ SeekBackPlayback()

static VOID SeekBackPlayback ( HWND  hwnd)
static

Definition at line 705 of file mplay32.c.

Referenced by MainWndProc().

706 {
707  MCI_STATUS_PARMS mciStatus;
708  DWORD dwNewPos;
709 
710  if (wDeviceId == 0) return;
711 
712  mciStatus.dwItem = MCI_STATUS_POSITION;
714 
715  dwNewPos = mciStatus.dwReturn - 1;
716 
717  if ((UINT)dwNewPos <= 1)
718  {
719  StopPlayback(hwnd);
720  }
721  else
722  {
723  SeekPlayback(hwnd, dwNewPos);
724  }
725 }
#define MCI_STATUS_ITEM
Definition: mmsystem.h:742
#define mciSendCommand
Definition: mmsystem.h:2851
#define MCI_STATUS_POSITION
Definition: mmsystem.h:745
WORD wDeviceId
Definition: mplay32.c:26
DWORD_PTR dwReturn
Definition: mmsystem.h:1567
#define MCI_STATUS
Definition: mmsystem.h:662
unsigned int UINT
Definition: ndis.h:50
unsigned long DWORD
Definition: ntddk_ex.h:95
uint32_t DWORD_PTR
Definition: typedefs.h:63
static VOID StopPlayback(HWND hwnd)
Definition: mplay32.c:646
static VOID SeekPlayback(HWND hwnd, DWORD dwNewPos)
Definition: mplay32.c:681

◆ SeekForwPlayback()

static VOID SeekForwPlayback ( HWND  hwnd)
static

Definition at line 728 of file mplay32.c.

Referenced by MainWndProc().

729 {
730  MCI_STATUS_PARMS mciStatus;
731  DWORD dwNewPos;
732 
733  if (wDeviceId == 0) return;
734 
735  mciStatus.dwItem = MCI_STATUS_POSITION;
737 
738  dwNewPos = mciStatus.dwReturn + 1;
739 
740  if ((UINT)dwNewPos >= MaxFilePos)
741  {
742  StopPlayback(hwnd);
743  }
744  else
745  {
746  SeekPlayback(hwnd, dwNewPos);
747  }
748 }
#define MCI_STATUS_ITEM
Definition: mmsystem.h:742
UINT MaxFilePos
Definition: mplay32.c:29
#define mciSendCommand
Definition: mmsystem.h:2851
#define MCI_STATUS_POSITION
Definition: mmsystem.h:745
WORD wDeviceId
Definition: mplay32.c:26
DWORD_PTR dwReturn
Definition: mmsystem.h:1567
#define MCI_STATUS
Definition: mmsystem.h:662
unsigned int UINT
Definition: ndis.h:50
unsigned long DWORD
Definition: ntddk_ex.h:95
uint32_t DWORD_PTR
Definition: typedefs.h:63
static VOID StopPlayback(HWND hwnd)
Definition: mplay32.c:646
static VOID SeekPlayback(HWND hwnd, DWORD dwNewPos)
Definition: mplay32.c:681

◆ SeekPlayback()

static VOID SeekPlayback ( HWND  hwnd,
DWORD  dwNewPos 
)
static

Definition at line 681 of file mplay32.c.

Referenced by MainWndProc(), SeekBackPlayback(), and SeekForwPlayback().

682 {
683  MCIERROR mciError;
684  MCI_SEEK_PARMS mciSeek;
685  MCI_PLAY_PARMS mciPlay;
686 
687  if (wDeviceId == 0) return;
688 
689  mciSeek.dwTo = (DWORD_PTR)dwNewPos;
690  mciError = mciSendCommand(wDeviceId, MCI_SEEK, MCI_WAIT | MCI_TO, (DWORD_PTR)&mciSeek);
691  if (mciError != 0)
692  {
693  ShowMCIError(hwnd, mciError);
694  }
695 
696  mciPlay.dwCallback = (DWORD_PTR)hwnd;
697  mciError = mciSendCommand(wDeviceId, MCI_PLAY, MCI_NOTIFY, (DWORD_PTR)&mciPlay);
698  if (mciError != 0)
699  {
700  ShowMCIError(hwnd, mciError);
701  }
702 }
#define DWORD_PTR
Definition: treelist.c:76
#define MCI_WAIT
Definition: mmsystem.h:730
#define mciSendCommand
Definition: mmsystem.h:2851
static VOID ShowMCIError(HWND hwnd, MCIERROR mciError)
Definition: mplay32.c:282
DWORD_PTR dwCallback
Definition: mmsystem.h:1537
#define MCI_PLAY
Definition: mmsystem.h:649
WORD wDeviceId
Definition: mplay32.c:26
DWORD MCIERROR
Definition: mmsystem.h:958
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define MCI_NOTIFY
Definition: mmsystem.h:729
#define MCI_SEEK
Definition: mmsystem.h:650
#define MCI_TO
Definition: mmsystem.h:732

◆ SetImageList()

static VOID SetImageList ( HWND  hwnd)
static

Definition at line 232 of file mplay32.c.

Referenced by CMainToolbar::Create(), DECLARE_INTERFACE_(), InitControls(), CSideTreeView::SetImageList(), and CMenuToolbarBase::UpdateImageLists().

233 {
234  HIMAGELIST hImageList;
235 
236  hImageList = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR24, 1, 1);
237  if (!hImageList)
238  {
239  ShowLastWin32Error(hwnd);
240  return;
241  }
242 
243  ImageList_AddMasked(hImageList,
245  RGB(255, 255, 255));
246 
247  ImageList_AddMasked(hImageList,
249  RGB(255, 255, 255));
250 
251  ImageList_AddMasked(hImageList,
253  RGB(255, 255, 255));
254 
255  ImageList_AddMasked(hImageList,
257  RGB(255, 255, 255));
258 
259  ImageList_AddMasked(hImageList,
261  RGB(255, 255, 255));
262 
263  ImageList_AddMasked(hImageList,
265  RGB(255, 255, 255));
266 
267  ImageList_AddMasked(hImageList,
269  RGB(255, 255, 255));
270 
271  ImageList_AddMasked(hImageList,
273  RGB(255, 255, 255));
274 
277  0,
278  (LPARAM)hImageList));
279 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define IDB_SEEKBACKICON
Definition: resource.h:11
#define IDB_FORWARDICON
Definition: resource.h:13
HINSTANCE hInstance
Definition: mplay32.c:15
HWND hToolBar
Definition: mplay32.c:17
#define IDB_PLAYICON
Definition: resource.h:7
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:893
static VOID ShowLastWin32Error(HWND hwnd)
Definition: mplay32.c:207
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:769
#define IDB_BACKWARDICON
Definition: resource.h:10
LONG_PTR LPARAM
Definition: windef.h:208
#define IDB_STOPICON
Definition: resource.h:8
#define TB_SETIMAGELIST
Definition: commctrl.h:1120
#define IDB_SEEKFORWICON
Definition: resource.h:12
#define ILC_COLOR24
Definition: commctrl.h:342
#define IDB_PAUSEICON
Definition: resource.h:14
#define RGB(r, g, b)
Definition: wingdi.h:2917
#define ILC_MASK
Definition: commctrl.h:336
#define IMAGE_BITMAP
Definition: winuser.h:211
#define IDB_EJECTICON
Definition: resource.h:9
#define SendMessage
Definition: winuser.h:5709
#define LoadImage
Definition: winuser.h:5681
INT WINAPI ImageList_AddMasked(HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
Definition: imagelist.c:528
#define LR_DEFAULTCOLOR
Definition: winuser.h:1077

◆ ShowDeviceProperties()

static VOID ShowDeviceProperties ( HWND  hwnd)
static

Definition at line 862 of file mplay32.c.

Referenced by MainWndProc().

863 {
864  MCIERROR mciError;
865  MCI_GENERIC_PARMS mciGeneric;
866 
867  mciError = mciSendCommand(wDeviceId, MCI_CONFIGURE, MCI_WAIT, (DWORD_PTR)&mciGeneric);
868  if (mciError != 0)
869  {
870  ShowMCIError(hwnd, mciError);
871  }
872 }
#define MCI_WAIT
Definition: mmsystem.h:730
#define mciSendCommand
Definition: mmsystem.h:2851
static VOID ShowMCIError(HWND hwnd, MCIERROR mciError)
Definition: mplay32.c:282
WORD wDeviceId
Definition: mplay32.c:26
#define MCI_CONFIGURE
Definition: digitalv.h:45
DWORD MCIERROR
Definition: mmsystem.h:958
uint32_t DWORD_PTR
Definition: typedefs.h:63

◆ ShowLastWin32Error()

static VOID ShowLastWin32Error ( HWND  hwnd)
static

Definition at line 207 of file mplay32.c.

Referenced by _tWinMain(), InitControls(), and SetImageList().

208 {
209  LPTSTR lpMessageBuffer;
210  DWORD dwError = GetLastError();
211 
212  if (dwError == ERROR_SUCCESS)
213  return;
214 
218  NULL,
219  dwError,
221  (LPTSTR)&lpMessageBuffer,
222  0, NULL))
223  {
224  return;
225  }
226 
227  MessageBox(hwnd, lpMessageBuffer, szAppTitle, MB_OK | MB_ICONERROR);
228  LocalFree(lpMessageBuffer);
229 }
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
smooth NULL
Definition: ftsmooth.c:416
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:404
TCHAR szAppTitle[256]
Definition: mplay32.c:21
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FormatMessage
Definition: winbase.h:3609
#define MB_ICONERROR
Definition: winuser.h:781
#define MessageBox
Definition: winuser.h:5688
#define FORMAT_MESSAGE_IGNORE_INSERTS
Definition: winbase.h:401
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define MB_OK
Definition: winuser.h:784
#define LANG_USER_DEFAULT
Definition: tnerror.cpp:50

◆ ShowMCIError()

static VOID ShowMCIError ( HWND  hwnd,
MCIERROR  mciError 
)
static

Definition at line 282 of file mplay32.c.

Referenced by GetDeviceMode(), HandleDeviceMenuItem(), OpenMediaFile(), SeekPlayback(), ShowDeviceProperties(), StartPlayback(), StopPlayback(), SwitchViewMode(), and TogglePlaybackState().

283 {
284  TCHAR szErrorMessage[MAX_MCISTR];
285  TCHAR szTempMessage[MAX_MCISTR + 44];
286 
287  if (mciGetErrorString(mciError, szErrorMessage, ARRAYSIZE(szErrorMessage)) == FALSE)
288  {
289  LoadString(hInstance, IDS_DEFAULTMCIERRMSG, szErrorMessage, ARRAYSIZE(szErrorMessage));
290  }
291 
292  StringCbPrintf(szTempMessage, sizeof(szTempMessage), _T("MMSYS%lu: %s"), mciError, szErrorMessage);
293  MessageBox(hwnd, szTempMessage, szAppTitle, MB_OK | MB_ICONEXCLAMATION);
294 }
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
HINSTANCE hInstance
Definition: mplay32.c:15
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define StringCbPrintf
Definition: strsafe.h:544
TCHAR szAppTitle[256]
Definition: mplay32.c:21
#define MessageBox
Definition: winuser.h:5688
#define IDS_DEFAULTMCIERRMSG
Definition: resource.h:28
#define MB_OK
Definition: winuser.h:784
#define MAX_MCISTR
Definition: mplay32.c:13
#define LoadString
Definition: winuser.h:5685
#define mciGetErrorString
Definition: mmsystem.h:2855

◆ StartPlayback()

static VOID StartPlayback ( HWND  hwnd)
static

Definition at line 767 of file mplay32.c.

Referenced by MainWndProc(), OpenMediaFile(), and TogglePlaybackState().

768 {
769  MCIERROR mciError;
770  MCI_PLAY_PARMS mciPlay;
771  MCI_SEEK_PARMS mciSeek;
772 
774 
776 
777  mciPlay.dwCallback = (DWORD_PTR)hwnd;
778  mciPlay.dwFrom = 0;
779  mciPlay.dwTo = MaxFilePos;
780 
781  mciError = mciSendCommand(wDeviceId, MCI_PLAY, MCI_NOTIFY | MCI_FROM /*| MCI_TO*/, (DWORD_PTR)&mciPlay);
782  if (mciError != 0)
783  {
784  ShowMCIError(hwnd, mciError);
785  return;
786  }
787 
788  UpdateWindowCaption(hwnd);
789 
791  TB_SETCMDID,
792  0,
793  IDC_PAUSE);
796  IDC_PAUSE,
798 }
#define DWORD_PTR
Definition: treelist.c:76
#define MCI_WAIT
Definition: mmsystem.h:730
UINT MaxFilePos
Definition: mplay32.c:29
#define mciSendCommand
Definition: mmsystem.h:2851
static VOID ShowMCIError(HWND hwnd, MCIERROR mciError)
Definition: mplay32.c:282
DWORD_PTR dwCallback
Definition: mmsystem.h:1537
#define MCI_PLAY
Definition: mmsystem.h:649
HWND hToolBar
Definition: mplay32.c:17
#define IDC_PAUSE
Definition: resource.h:75
#define IDB_PLAYICON
Definition: resource.h:7
VOID(CALLBACK * TIMERPROC)(HWND, UINT, UINT_PTR, DWORD)
Definition: winuser.h:2850
WORD wDeviceId
Definition: mplay32.c:26
#define TB_SETCMDID
Definition: commctrl.h:1113
#define IDT_PLAYTIMER
Definition: mplay32.c:9
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define IDB_PAUSEICON
Definition: resource.h:14
DWORD MCIERROR
Definition: mmsystem.h:958
VOID CALLBACK PlayTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
Definition: mplay32.c:751
#define TB_CHANGEBITMAP
Definition: commctrl.h:1114
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define MCI_SEEK_TO_START
Definition: mmsystem.h:740
#define SendMessage
Definition: winuser.h:5709
#define MCI_FROM
Definition: mmsystem.h:731
#define MCI_NOTIFY
Definition: mmsystem.h:729
#define MCI_SEEK
Definition: mmsystem.h:650
void UpdateWindowCaption(HWND hwnd)
Definition: mplay32.c:96

◆ StopPlayback()

static VOID StopPlayback ( HWND  hwnd)
static

Definition at line 646 of file mplay32.c.

Referenced by CloseMediaFile(), MainWndProc(), SeekBackPlayback(), and SeekForwPlayback().

647 {
648  MCIERROR mciError;
649  MCI_GENERIC_PARMS mciGeneric;
650  MCI_SEEK_PARMS mciSeek;
651 
652  if (wDeviceId == 0) return;
653 
654  KillTimer(hwnd, IDT_PLAYTIMER);
656 
657  mciGeneric.dwCallback = (DWORD_PTR)hwnd;
658  mciError = mciSendCommand(wDeviceId, MCI_STOP, MCI_WAIT, (DWORD_PTR)&mciGeneric);
659  if (mciError != 0)
660  {
661  ShowMCIError(hwnd, mciError);
662  return;
663  }
664 
666 
668  UpdateWindowCaption(hwnd);
669 
671  TB_SETCMDID,
672  0,
673  IDC_PLAY);
676  IDC_PLAY,
678 }
HWND hTimeDisplay
Definition: mplay32.c:18
#define TRUE
Definition: types.h:120
HWND hTrackBar
Definition: mplay32.c:16
#define DWORD_PTR
Definition: treelist.c:76
#define MCI_WAIT
Definition: mmsystem.h:730
#define mciSendCommand
Definition: mmsystem.h:2851
static VOID ShowMCIError(HWND hwnd, MCIERROR mciError)
Definition: mplay32.c:282
#define TBM_SETPOS
Definition: commctrl.h:2006
HWND hToolBar
Definition: mplay32.c:17
#define IDB_PLAYICON
Definition: resource.h:7
WORD wDeviceId
Definition: mplay32.c:26
UINT_PTR WPARAM
Definition: windef.h:207
#define MCI_STOP
Definition: mmsystem.h:651
void UpdateTimeDisplay(HWND hwnd)
Definition: mplay32.c:161
#define TB_SETCMDID
Definition: commctrl.h:1113
LONG_PTR LPARAM
Definition: windef.h:208
#define IDT_PLAYTIMER
Definition: mplay32.c:9
DWORD MCIERROR
Definition: mmsystem.h:958
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define TB_CHANGEBITMAP
Definition: commctrl.h:1114
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define MCI_SEEK_TO_START
Definition: mmsystem.h:740
DWORD_PTR dwCallback
Definition: mmsystem.h:1517
#define IDC_PLAY
Definition: resource.h:68
#define SendMessage
Definition: winuser.h:5709
#define MCI_SEEK
Definition: mmsystem.h:650
void UpdateWindowCaption(HWND hwnd)
Definition: mplay32.c:96

◆ SwitchViewMode()

static VOID SwitchViewMode ( HWND  hwnd)
static

Definition at line 365 of file mplay32.c.

Referenced by CloseMediaFile(), and MainWndProc().

366 {
367  MCIERROR mciError;
368  MCI_DGV_RECT_PARMS mciVideoRect;
369  MCI_DGV_WINDOW_PARMSW mciVideoWindow;
370  RECT rcToolbarRect;
371  RECT rcTempRect;
372 
373  mciVideoWindow.hWnd = hwnd;
374 
375  mciError = mciSendCommand(wDeviceId, MCI_WINDOW, MCI_DGV_WINDOW_HWND | MCI_TEST, (DWORD_PTR)&mciVideoWindow);
376  if (mciError != 0)
377  return;
378 
380  if (mciError != 0)
381  return;
382 
383  if (!bIsSingleWindow)
384  {
386 
388 
389  mciError = mciSendCommand(wDeviceId, MCI_WHERE, MCI_DGV_WHERE_SOURCE, (DWORD_PTR)&mciVideoRect);
390  if (mciError != 0)
391  {
392  ShowMCIError(hwnd, mciError);
393  return;
394  }
395 
396  GetWindowRect(hToolBar, &rcToolbarRect);
397  ResizeClientArea(hwnd, mciVideoRect.rc.right, mciVideoRect.rc.bottom + (rcToolbarRect.bottom - rcToolbarRect.top));
398 
399  mciError = mciSendCommand(wDeviceId, MCI_WINDOW, MCI_DGV_WINDOW_HWND, (DWORD_PTR)&mciVideoWindow);
400  if (mciError != 0)
401  {
402  ShowMCIError(hwnd, mciError);
403  return;
404  }
405 
406  GetWindowRect(hToolBar, &rcTempRect);
407  MoveWindow(hTrackBar, 180, 0, rcTempRect.right - rcTempRect.left - 322, 25, TRUE);
408  MoveWindow(hTimeDisplay, rcTempRect.right - rcTempRect.left - 140, 4, 135, 18, TRUE);
409 
412  }
413  else
414  {
417 
418  mciVideoWindow.hWnd = MCI_DGV_WINDOW_DEFAULT;
419  mciError = mciSendCommand(wDeviceId, MCI_WINDOW, MCI_DGV_WINDOW_HWND, (DWORD_PTR)&mciVideoWindow);
420  if (mciError != 0)
421  {
422  ShowMCIError(hwnd, mciError);
423  return;
424  }
425 
426  SetParent(hTrackBar, hwnd);
427 
429  }
430 }
HWND hTimeDisplay
Definition: mplay32.c:18
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
#define MF_BYCOMMAND
Definition: winuser.h:202
HWND hTrackBar
Definition: mplay32.c:16
HWND WINAPI SetParent(_In_ HWND, _In_opt_ HWND)
#define mciSendCommand
Definition: mmsystem.h:2851
static VOID ShowMCIError(HWND hwnd, MCIERROR mciError)
Definition: mplay32.c:282
LONG top
Definition: windef.h:297
HWND hToolBar
Definition: mplay32.c:17
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
WORD wDeviceId
Definition: mplay32.c:26
#define MCI_WINDOW
Definition: mmsystem.h:665
HMENU hMainMenu
Definition: mplay32.c:19
#define MCI_WHERE
Definition: mmsystem.h:667
void ResizeClientArea(HWND hwnd, int nWidth, int nHeight)
Definition: mplay32.c:83
#define MCI_DGV_WHERE_SOURCE
Definition: digitalv.h:444
#define MCI_DGV_WINDOW_DEFAULT
Definition: digitalv.h:459
#define IDM_SWITCHVIEW
Definition: resource.h:53
BOOL bIsSingleWindow
Definition: mplay32.c:28
#define MCI_DGV_WINDOW_HWND
Definition: digitalv.h:453
#define MF_CHECKED
Definition: winuser.h:132
#define MCI_TEST
Definition: digitalv.h:32
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
DWORD MCIERROR
Definition: mmsystem.h:958
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define MF_UNCHECKED
Definition: winuser.h:204
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
RECT PrevWindowPos
Definition: mplay32.c:30
LONG bottom
Definition: windef.h:299
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)

◆ TogglePlaybackState()

static VOID TogglePlaybackState ( HWND  hwnd)
static

Definition at line 801 of file mplay32.c.

Referenced by MainWndProc().

802 {
803  MCIERROR mciError;
804  MCI_GENERIC_PARMS mciGeneric;
805  ULONG idBmp = IDB_PLAYICON;
806  ULONG idCmd = IDC_PLAY;
807 
808  if (wDeviceId == 0) return;
809 
810  switch (GetDeviceMode(hwnd))
811  {
812  case MCI_MODE_OPEN:
813  case MCI_MODE_STOP:
814  {
815  StartPlayback(hwnd);
816  return;
817  }
818 
819  case MCI_MODE_PLAY:
820  {
821  mciGeneric.dwCallback = (DWORD_PTR)hwnd;
822  mciError = mciSendCommand(wDeviceId, MCI_PAUSE, MCI_WAIT, (DWORD_PTR)&mciGeneric);
823  idBmp = IDB_PLAYICON;
824  idCmd = IDC_PLAY;
825  break;
826  }
827 
828  case MCI_MODE_PAUSE:
829  {
830  mciGeneric.dwCallback = (DWORD_PTR)hwnd;
831  mciError = mciSendCommand(wDeviceId, MCI_RESUME, MCI_WAIT, (DWORD_PTR)&mciGeneric);
832  idBmp = IDB_PAUSEICON;
833  idCmd = IDC_PAUSE;
834  break;
835  }
836 
837  default:
838  {
839  return;
840  }
841  }
842 
843  if (mciError != 0)
844  {
845  ShowMCIError(hwnd, mciError);
846  return;
847  }
848 
849  UpdateWindowCaption(hwnd);
850 
852  TB_SETCMDID,
853  0,
854  idCmd);
857  idCmd,
858  idBmp - IDB_PLAYICON);
859 }
#define MCI_MODE_STOP
Definition: mmsystem.h:695
#define DWORD_PTR
Definition: treelist.c:76
#define MCI_WAIT
Definition: mmsystem.h:730
#define mciSendCommand
Definition: mmsystem.h:2851
static VOID ShowMCIError(HWND hwnd, MCIERROR mciError)
Definition: mplay32.c:282
#define MCI_RESUME
Definition: mmsystem.h:675
HWND hToolBar
Definition: mplay32.c:17
static VOID StartPlayback(HWND hwnd)
Definition: mplay32.c:767
#define IDC_PAUSE
Definition: resource.h:75
#define IDB_PLAYICON
Definition: resource.h:7
WORD wDeviceId
Definition: mplay32.c:26
#define TB_SETCMDID
Definition: commctrl.h:1113
#define MCI_MODE_PLAY
Definition: mmsystem.h:696
#define IDB_PAUSEICON
Definition: resource.h:14
static DWORD GetDeviceMode(HWND hwnd)
Definition: mplay32.c:629
DWORD MCIERROR
Definition: mmsystem.h:958
#define TB_CHANGEBITMAP
Definition: commctrl.h:1114
uint32_t DWORD_PTR
Definition: typedefs.h:63
DWORD_PTR dwCallback
Definition: mmsystem.h:1517
#define IDC_PLAY
Definition: resource.h:68
#define SendMessage
Definition: winuser.h:5709
#define MCI_MODE_PAUSE
Definition: mmsystem.h:699
#define MCI_PAUSE
Definition: mmsystem.h:652
#define MCI_MODE_OPEN
Definition: mmsystem.h:700
unsigned int ULONG
Definition: retypes.h:1
void UpdateWindowCaption(HWND hwnd)
Definition: mplay32.c:96

◆ UpdateTimeDisplay()

void UpdateTimeDisplay ( HWND  hwnd)

Definition at line 161 of file mplay32.c.

Referenced by CloseMciDevice(), OpenMciDevice(), PlayTimerProc(), and StopPlayback().

162 {
163  MCI_STATUS_PARMS mciStatus;
165  DWORD dwTimeFormat;
166 
167  if (!wDeviceId)
168  {
169  SetWindowText(hwnd, _T(""));
170  return;
171  }
172 
173  mciStatus.dwItem = MCI_STATUS_TIME_FORMAT;
174  mciStatus.dwReturn = 0;
176  dwTimeFormat = mciStatus.dwReturn;
177 
178  mciStatus.dwItem = MCI_STATUS_POSITION;
179  mciStatus.dwReturn = 0;
181 
182  switch(dwTimeFormat)
183  {
185  {
186  int s, m, h;
187 
188  s = (mciStatus.dwReturn / 1000) % 60;
189  m = ((mciStatus.dwReturn / (1000*60)) % 60);
190  h = ((mciStatus.dwReturn / (1000*60*60)) % 24);
191  StringCbPrintf(szTime, sizeof(szTime), _T("%02lu:%02lu:%02lu"), h, m, s);
192  break;
193  }
194 
195  /* The time format is unknown, so use the returned position as is */
196  default:
197  {
198  StringCbPrintf(szTime, sizeof(szTime), _T("%lu"), mciStatus.dwReturn);
199  break;
200  }
201  }
202 
203  SetWindowText(hwnd, szTime);
204 }
#define MCI_STATUS_ITEM
Definition: mmsystem.h:742
TCHAR szTime[64]
Definition: solitaire.cpp:18
#define mciSendCommand
Definition: mmsystem.h:2851
#define MCI_STATUS_POSITION
Definition: mmsystem.h:745
WORD wDeviceId
Definition: mplay32.c:26
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
DWORD_PTR dwReturn
Definition: mmsystem.h:1567
#define MCI_FORMAT_MILLISECONDS
Definition: mmsystem.h:701
#define MCI_STATUS
Definition: mmsystem.h:662
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define StringCbPrintf
Definition: strsafe.h:544
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble s
Definition: gl.h:2039
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define SetWindowText
Definition: winuser.h:5723
#define MAX_MCISTR
Definition: mplay32.c:13
CONST GLfloat m[16]
Definition: m_xform.h:144
#define MCI_STATUS_TIME_FORMAT
Definition: mmsystem.h:749

◆ UpdateWindowCaption()

void UpdateWindowCaption ( HWND  hwnd)

Definition at line 96 of file mplay32.c.

Referenced by CloseMediaFile(), EDIT_WndProc(), OpenMciDevice(), StartPlayback(), StopPlayback(), and TogglePlaybackState().

97 {
98  TCHAR szNewTitle[MAX_PATH + 3 + 256];
99  TCHAR szStatus[128];
100 
101  if (wDeviceId == 0)
102  {
103  SetWindowText(hwnd, szAppTitle);
104  return;
105  }
106 
107  switch (GetDeviceMode(hwnd))
108  {
109  case MCI_MODE_PAUSE:
110  {
111  LoadString(hInstance, IDS_MODE_PAUSE, szStatus, ARRAYSIZE(szStatus));
112  break;
113  }
114 
115  case MCI_MODE_STOP:
116  {
117  LoadString(hInstance, IDS_MODE_STOP, szStatus, ARRAYSIZE(szStatus));
118  break;
119  }
120 
121  case MCI_MODE_PLAY:
122  {
123  LoadString(hInstance, IDS_MODE_PLAY, szStatus, ARRAYSIZE(szStatus));
124  break;
125  }
126 
127  case MCI_MODE_OPEN:
128  {
129  LoadString(hInstance, IDS_MODE_OPEN, szStatus, ARRAYSIZE(szStatus));
130  break;
131  }
132 
133  case MCI_MODE_RECORD:
134  {
135  LoadString(hInstance, IDS_MODE_RECORD, szStatus, ARRAYSIZE(szStatus));
136  break;
137  }
138 
139  case MCI_MODE_SEEK:
140  {
141  LoadString(hInstance, IDS_MODE_SEEK, szStatus, ARRAYSIZE(szStatus));
142  break;
143  }
144 
145  case MCI_MODE_NOT_READY:
146  {
147  LoadString(hInstance, IDS_MODE_NOT_READY, szStatus, ARRAYSIZE(szStatus));
148  break;
149  }
150 
151  default:
152  {
153  LoadString(hInstance, IDS_MODE_UNKNOWN, szStatus, ARRAYSIZE(szStatus));
154  }
155  }
156 
157  StringCbPrintf(szNewTitle, sizeof(szNewTitle), _T("%s - %s (%s)"), szAppTitle, szCurrentFile, szStatus);
158  SetWindowText(hwnd, szNewTitle);
159 }
#define MCI_MODE_STOP
Definition: mmsystem.h:695
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
HINSTANCE hInstance
Definition: mplay32.c:15
WORD wDeviceId
Definition: mplay32.c:26
#define MCI_MODE_RECORD
Definition: mmsystem.h:697
#define MCI_MODE_PLAY
Definition: mmsystem.h:696
#define IDS_MODE_NOT_READY
Definition: resource.h:37
#define IDS_MODE_OPEN
Definition: resource.h:31
TCHAR szCurrentFile[MAX_PATH]
Definition: mplay32.c:23
#define IDS_MODE_PLAY
Definition: resource.h:33
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define IDS_MODE_STOP
Definition: resource.h:32
#define IDS_MODE_SEEK
Definition: resource.h:36
static const WCHAR szStatus[]
Definition: http.c:73
#define StringCbPrintf
Definition: strsafe.h:544
#define MAX_PATH
Definition: compat.h:26
TCHAR szAppTitle[256]
Definition: mplay32.c:21
static DWORD GetDeviceMode(HWND hwnd)
Definition: mplay32.c:629
#define IDS_MODE_UNKNOWN
Definition: resource.h:30
#define MCI_MODE_NOT_READY
Definition: mmsystem.h:694
#define MCI_MODE_SEEK
Definition: mmsystem.h:698
#define SetWindowText
Definition: winuser.h:5723
#define MCI_MODE_PAUSE
Definition: mmsystem.h:699
#define MCI_MODE_OPEN
Definition: mmsystem.h:700
#define LoadString
Definition: winuser.h:5685
#define IDS_MODE_PAUSE
Definition: resource.h:34
#define IDS_MODE_RECORD
Definition: resource.h:35

Variable Documentation

◆ bIsSingleWindow

BOOL bIsSingleWindow = FALSE

Definition at line 28 of file mplay32.c.

Referenced by CloseMediaFile(), MainWndProc(), and SwitchViewMode().

◆ bRepeat

BOOL bRepeat = FALSE

Definition at line 27 of file mplay32.c.

Referenced by MainWndProc().

◆ Buttons

const TBBUTTON Buttons[]
static
Initial value:
=
{
{15, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},
}
#define IDC_SEEKBACK
Definition: resource.h:72
#define IDC_BACKWARD
Definition: resource.h:71
#define IDC_SEEKFORW
Definition: resource.h:73
#define TBICON_PLAY
Definition: resource.h:59
#define BTNS_BUTTON
Definition: commctrl.h:968
#define TBICON_EJECT
Definition: resource.h:61
#define IDC_STOP
Definition: resource.h:69
#define TBICON_FORWARD
Definition: resource.h:65
#define BTNS_SEP
Definition: commctrl.h:969
#define IDC_EJECT
Definition: resource.h:70
#define TBICON_SEEKFORW
Definition: resource.h:64
#define IDC_FORWARD
Definition: resource.h:74
#define TBICON_BACKWARD
Definition: resource.h:62
#define IDC_PLAY
Definition: resource.h:68
#define TBICON_SEEKBACK
Definition: resource.h:63
#define TBICON_STOP
Definition: resource.h:60
#define TBSTATE_ENABLED
Definition: commctrl.h:944

Definition at line 35 of file mplay32.c.

Referenced by CMainToolbar::Create(), CardWindow::CreateButton(), KbdHid_StartDevice(), MessageBoxTimeoutIndirectW(), and MouHid_StartDevice().

◆ hInstance

HINSTANCE hInstance = NULL

Definition at line 15 of file mplay32.c.

Referenced by _tWinMain(), and OpenFileDialog().

◆ hMainMenu

◆ hTimeDisplay

HWND hTimeDisplay = NULL

Definition at line 18 of file mplay32.c.

◆ hToolBar

HWND hToolBar = NULL

Definition at line 17 of file mplay32.c.

Referenced by _CmdWndProc(), HSplitterWindowProc(), resize_frame_rect(), and VSplitterWindowProc().

◆ hTrackBar

HWND hTrackBar = NULL

Definition at line 16 of file mplay32.c.

◆ MaxFilePos

UINT MaxFilePos = 0

Definition at line 29 of file mplay32.c.

Referenced by OpenMciDevice(), SeekForwPlayback(), and StartPlayback().

◆ PrevWindowPos

RECT PrevWindowPos

Definition at line 30 of file mplay32.c.

◆ szAppTitle

TCHAR szAppTitle[256] = _T("")

◆ szCurrentFile

TCHAR szCurrentFile[MAX_PATH] = _T("")

Definition at line 23 of file mplay32.c.

Referenced by DebuggerShell(), LoadSymbolsFromConfig(), OpenMciDevice(), and UpdateWindowCaption().

◆ szDefaultFilter

TCHAR szDefaultFilter[MAX_PATH] = _T("")

Definition at line 22 of file mplay32.c.

Referenced by BuildFileFilterAndDeviceMenu(), and CleanupFileFilter().

◆ szFilter

◆ wDeviceId