Author: akhaldi Date: Fri Mar 20 10:13:11 2015 New Revision: 66831
URL: http://svn.reactos.org/svn/reactos?rev=66831&view=rev Log: [MPLAY32] Display the current media position. By Ricardo Hanke. CORE-9396
Modified: trunk/reactos/base/applications/mplay32/mplay32.c
Modified: trunk/reactos/base/applications/mplay32/mplay32.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mplay32/m... ============================================================================== --- trunk/reactos/base/applications/mplay32/mplay32.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/mplay32/mplay32.c [iso-8859-1] Fri Mar 20 10:13:11 2015 @@ -15,6 +15,7 @@ HINSTANCE hInstance = NULL; HWND hTrackBar = NULL; HWND hToolBar = NULL; +HWND hTimeDisplay = NULL; HMENU hMainMenu = NULL;
TCHAR szAppTitle[256] = _T(""); @@ -155,6 +156,51 @@
StringCbPrintf(szNewTitle, sizeof(szNewTitle), _T("%s - %s (%s)"), szAppTitle, szCurrentFile, szStatus); SetWindowText(hwnd, szNewTitle); +} + +void UpdateTimeDisplay(HWND hwnd) +{ + MCI_STATUS_PARMS mciStatus; + TCHAR szTime[MAX_MCISTR]; + DWORD dwTimeFormat; + + if (!wDeviceId) + { + SetWindowText(hwnd, _T("")); + return; + } + + mciStatus.dwItem = MCI_STATUS_TIME_FORMAT; + mciStatus.dwReturn = 0; + mciSendCommand(wDeviceId, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&mciStatus); + dwTimeFormat = mciStatus.dwReturn; + + mciStatus.dwItem = MCI_STATUS_POSITION; + mciStatus.dwReturn = 0; + mciSendCommand(wDeviceId, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&mciStatus); + + switch(dwTimeFormat) + { + case MCI_FORMAT_MILLISECONDS: + { + int s, m, h; + + s = (mciStatus.dwReturn / 1000) % 60; + m = ((mciStatus.dwReturn / (1000*60)) % 60); + h = ((mciStatus.dwReturn / (1000*60*60)) % 24); + StringCbPrintf(szTime, sizeof(szTime), _T("%02lu:%02lu:%02lu"), h, m, s); + break; + } + + /* The time format is unknown, so use the returned position as is */ + default: + { + StringCbPrintf(szTime, sizeof(szTime), _T("%lu"), mciStatus.dwReturn); + break; + } + } + + SetWindowText(hwnd, szTime); }
static VOID @@ -286,6 +332,24 @@ return; }
+ hTimeDisplay = CreateWindowEx(0, + L"STATIC", + NULL, + WS_CHILD | WS_VISIBLE | SS_CENTER | SS_SUNKEN, + 195, + 4, + 135, + 18, + hToolBar, + NULL, + hInstance, + NULL); + if (!hTimeDisplay) + { + ShowLastWin32Error(hwnd); + return; + } + SetImageList(hwnd); SendMessage(hToolBar, TB_ADDBUTTONS, NumButtons, (LPARAM)Buttons); } @@ -333,7 +397,8 @@ }
GetWindowRect(hToolBar, &rcTempRect); - MoveWindow(hTrackBar, 180, 0, rcTempRect.right - rcTempRect.left - 180, 25, TRUE); + MoveWindow(hTrackBar, 180, 0, rcTempRect.right - rcTempRect.left - 322, 25, TRUE); + MoveWindow(hTimeDisplay, rcTempRect.right - rcTempRect.left - 140, 4, 135, 18, TRUE);
CheckMenuItem(hMainMenu, IDM_SWITCHVIEW, MF_BYCOMMAND | MF_CHECKED); bIsSingleWindow = TRUE; @@ -431,6 +496,8 @@ wDeviceId = 0; }
+ UpdateTimeDisplay(hTimeDisplay); + DisableMenuItems();
return 0; @@ -505,6 +572,7 @@
EnableMenuItems(hwnd);
+ UpdateTimeDisplay(hTimeDisplay); UpdateWindowCaption(hwnd);
return 0; @@ -535,8 +603,8 @@
if (wDeviceId == 0) return;
+ KillTimer(hwnd, IDT_PLAYTIMER); SendMessage(hTrackBar, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)1); - KillTimer(hwnd, IDT_PLAYTIMER);
mciGeneric.dwCallback = (DWORD_PTR)hwnd; mciError = mciSendCommand(wDeviceId, MCI_STOP, MCI_NOTIFY, (DWORD_PTR)&mciGeneric); @@ -548,6 +616,7 @@
mciSendCommand(wDeviceId, MCI_SEEK, MCI_WAIT | MCI_SEEK_TO_START, 0);
+ UpdateTimeDisplay(hTimeDisplay); UpdateWindowCaption(hwnd);
SendMessage(hToolBar, @@ -659,6 +728,7 @@ else { SendMessage(hTrackBar, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)dwPos); + UpdateTimeDisplay(hTimeDisplay); } }
@@ -1115,6 +1185,7 @@ { SendMessage(hToolBar, TB_AUTOSIZE, 0, 0); SendMessage(hToolBar, TB_GETITEMRECT, 1, (LPARAM)&Rect); + MoveWindow(hTimeDisplay, LOWORD(lParam) - 140, 4, 135, 18, TRUE);
if (!bIsSingleWindow) { @@ -1126,7 +1197,7 @@ RECT ToolbarRect; MCI_DGV_PUT_PARMS mciPut;
- MoveWindow(hTrackBar, 180, 0, LOWORD(lParam) - 180, 25, TRUE); + MoveWindow(hTrackBar, 180, 0, LOWORD(lParam) - 322, 25, TRUE);
GetClientRect(hwnd, &Rect); GetClientRect(hToolBar, &ToolbarRect);