2 * PROJECT: ReactOS Multimedia Player
3 * FILE: base/applications/mplay32/mplay32.c
4 * PROGRAMMERS: Dmitry Chapyshev (dmitry@reactos.org)
9 #define IDT_PLAYTIMER 1000
11 #define MAIN_WINDOW_HEIGHT 125
12 #define MAIN_WINDOW_MIN_WIDTH 250
13 #define MAX_MCISTR 256
15 HINSTANCE hInstance
= NULL
;
16 HWND hTrackBar
= NULL
;
18 HWND hTimeDisplay
= NULL
;
19 HMENU hMainMenu
= NULL
;
21 TCHAR szAppTitle
[256] = _T("");
22 TCHAR szDefaultFilter
[MAX_PATH
] = _T("");
23 TCHAR szCurrentFile
[MAX_PATH
] = _T("");
24 LPTSTR szFilter
= NULL
;
28 BOOL bIsSingleWindow
= FALSE
;
32 static DWORD
GetDeviceMode(HWND hwnd
);
35 static const TBBUTTON Buttons
[] =
36 { /* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
37 {TBICON_PLAY
, IDC_PLAY
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0}, 0, 0},
38 {TBICON_STOP
, IDC_STOP
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0}, 0, 0},
39 {TBICON_EJECT
, IDC_EJECT
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0}, 0, 0},
40 {15, 0, TBSTATE_ENABLED
, BTNS_SEP
, {0}, 0, 0},
41 {TBICON_BACKWARD
, IDC_BACKWARD
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0}, 0, 0},
42 {TBICON_SEEKBACK
, IDC_SEEKBACK
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0}, 0, 0},
43 {TBICON_SEEKFORW
, IDC_SEEKFORW
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0}, 0, 0},
44 {TBICON_FORWARD
, IDC_FORWARD
, TBSTATE_ENABLED
, BTNS_BUTTON
, {0}, 0, 0},
45 // {TBICON_PAUSE, IDC_PAUSE, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}
48 void EnableMenuItems(HWND hwnd
)
51 MCI_GENERIC_PARMS mciGeneric
;
52 MCI_DGV_RECT_PARMS mciVideoRect
;
53 MCI_DGV_WINDOW_PARMSW mciVideoWindow
;
55 EnableMenuItem(hMainMenu
, IDM_CLOSE_FILE
, MF_BYCOMMAND
| MF_ENABLED
);
57 mciError
= mciSendCommand(wDeviceId
, MCI_CONFIGURE
, MCI_TEST
, (DWORD_PTR
)&mciGeneric
);
60 EnableMenuItem(hMainMenu
, IDM_DEVPROPS
, MF_BYCOMMAND
| MF_ENABLED
);
63 mciVideoWindow
.hWnd
= hwnd
;
65 mciError
= mciSendCommand(wDeviceId
, MCI_WINDOW
, MCI_DGV_WINDOW_HWND
| MCI_TEST
, (DWORD_PTR
)&mciVideoWindow
);
68 mciError
= mciSendCommand(wDeviceId
, MCI_WHERE
, MCI_DGV_WHERE_SOURCE
| MCI_TEST
, (DWORD_PTR
)&mciVideoRect
);
71 EnableMenuItem(hMainMenu
, IDM_SWITCHVIEW
, MF_BYCOMMAND
| MF_ENABLED
);
76 void DisableMenuItems(void)
78 EnableMenuItem(hMainMenu
, IDM_CLOSE_FILE
, MF_BYCOMMAND
| MF_GRAYED
);
79 EnableMenuItem(hMainMenu
, IDM_DEVPROPS
, MF_BYCOMMAND
| MF_GRAYED
);
80 EnableMenuItem(hMainMenu
, IDM_SWITCHVIEW
, MF_BYCOMMAND
| MF_GRAYED
);
83 void ResizeClientArea(HWND hwnd
, int nWidth
, int nHeight
)
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
);
96 void UpdateWindowCaption(HWND hwnd
)
98 TCHAR szNewTitle
[MAX_PATH
+ 3 + 256];
103 SetWindowText(hwnd
, szAppTitle
);
107 switch (GetDeviceMode(hwnd
))
111 LoadString(hInstance
, IDS_MODE_PAUSE
, szStatus
, ARRAYSIZE(szStatus
));
117 LoadString(hInstance
, IDS_MODE_STOP
, szStatus
, ARRAYSIZE(szStatus
));
123 LoadString(hInstance
, IDS_MODE_PLAY
, szStatus
, ARRAYSIZE(szStatus
));
129 LoadString(hInstance
, IDS_MODE_OPEN
, szStatus
, ARRAYSIZE(szStatus
));
133 case MCI_MODE_RECORD
:
135 LoadString(hInstance
, IDS_MODE_RECORD
, szStatus
, ARRAYSIZE(szStatus
));
141 LoadString(hInstance
, IDS_MODE_SEEK
, szStatus
, ARRAYSIZE(szStatus
));
145 case MCI_MODE_NOT_READY
:
147 LoadString(hInstance
, IDS_MODE_NOT_READY
, szStatus
, ARRAYSIZE(szStatus
));
153 LoadString(hInstance
, IDS_MODE_UNKNOWN
, szStatus
, ARRAYSIZE(szStatus
));
157 StringCbPrintf(szNewTitle
, sizeof(szNewTitle
), _T("%s - %s (%s)"), szAppTitle
, szCurrentFile
, szStatus
);
158 SetWindowText(hwnd
, szNewTitle
);
161 void UpdateTimeDisplay(HWND hwnd
)
163 MCI_STATUS_PARMS mciStatus
;
164 TCHAR szTime
[MAX_MCISTR
];
169 SetWindowText(hwnd
, _T(""));
173 mciStatus
.dwItem
= MCI_STATUS_TIME_FORMAT
;
174 mciStatus
.dwReturn
= 0;
175 mciSendCommand(wDeviceId
, MCI_STATUS
, MCI_STATUS_ITEM
, (DWORD_PTR
)&mciStatus
);
176 dwTimeFormat
= mciStatus
.dwReturn
;
178 mciStatus
.dwItem
= MCI_STATUS_POSITION
;
179 mciStatus
.dwReturn
= 0;
180 mciSendCommand(wDeviceId
, MCI_STATUS
, MCI_STATUS_ITEM
, (DWORD_PTR
)&mciStatus
);
184 case MCI_FORMAT_MILLISECONDS
:
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
);
195 /* The time format is unknown, so use the returned position as is */
198 StringCbPrintf(szTime
, sizeof(szTime
), _T("%lu"), mciStatus
.dwReturn
);
203 SetWindowText(hwnd
, szTime
);
207 ShowLastWin32Error(HWND hwnd
)
209 LPTSTR lpMessageBuffer
;
210 DWORD dwError
= GetLastError();
212 if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM
,
215 MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
),
216 (LPTSTR
)&lpMessageBuffer
,
219 MessageBox(hwnd
, lpMessageBuffer
, szAppTitle
, MB_OK
| MB_ICONERROR
);
220 if (lpMessageBuffer
) LocalFree(lpMessageBuffer
);
225 SetImageList(HWND hwnd
)
227 HIMAGELIST hImageList
;
229 hImageList
= ImageList_Create(16, 16, ILC_MASK
| ILC_COLOR24
, 1, 1);
232 ShowLastWin32Error(hwnd
);
236 ImageList_AddMasked(hImageList
,
237 LoadImage(hInstance
, MAKEINTRESOURCE(IDB_PLAYICON
), IMAGE_BITMAP
, 16, 16, LR_DEFAULTCOLOR
),
240 ImageList_AddMasked(hImageList
,
241 LoadImage(hInstance
, MAKEINTRESOURCE(IDB_STOPICON
), IMAGE_BITMAP
, 16, 16, LR_DEFAULTCOLOR
),
244 ImageList_AddMasked(hImageList
,
245 LoadImage(hInstance
, MAKEINTRESOURCE(IDB_EJECTICON
), IMAGE_BITMAP
, 16, 16, LR_DEFAULTCOLOR
),
248 ImageList_AddMasked(hImageList
,
249 LoadImage(hInstance
, MAKEINTRESOURCE(IDB_BACKWARDICON
), IMAGE_BITMAP
, 16, 16, LR_DEFAULTCOLOR
),
252 ImageList_AddMasked(hImageList
,
253 LoadImage(hInstance
, MAKEINTRESOURCE(IDB_SEEKBACKICON
), IMAGE_BITMAP
, 16, 16, LR_DEFAULTCOLOR
),
256 ImageList_AddMasked(hImageList
,
257 LoadImage(hInstance
, MAKEINTRESOURCE(IDB_SEEKFORWICON
), IMAGE_BITMAP
, 16, 16, LR_DEFAULTCOLOR
),
260 ImageList_AddMasked(hImageList
,
261 LoadImage(hInstance
, MAKEINTRESOURCE(IDB_FORWARDICON
), IMAGE_BITMAP
, 16, 16, LR_DEFAULTCOLOR
),
264 ImageList_AddMasked(hImageList
,
265 LoadImage(hInstance
, MAKEINTRESOURCE(IDB_PAUSEICON
), IMAGE_BITMAP
, 16, 16, LR_DEFAULTCOLOR
),
268 ImageList_Destroy((HIMAGELIST
)SendMessage(hToolBar
,
271 (LPARAM
)hImageList
));
275 ShowMCIError(HWND hwnd
, MCIERROR mciError
)
277 TCHAR szErrorMessage
[MAX_MCISTR
];
278 TCHAR szTempMessage
[MAX_MCISTR
+ 44];
280 if (mciGetErrorString(mciError
, szErrorMessage
, ARRAYSIZE(szErrorMessage
)) == FALSE
)
282 LoadString(hInstance
, IDS_DEFAULTMCIERRMSG
, szErrorMessage
, ARRAYSIZE(szErrorMessage
));
285 StringCbPrintf(szTempMessage
, sizeof(szTempMessage
), _T("MMSYS%lu: %s"), mciError
, szErrorMessage
);
286 MessageBox(hwnd
, szTempMessage
, szAppTitle
, MB_OK
| MB_ICONEXCLAMATION
);
290 InitControls(HWND hwnd
)
292 INT NumButtons
= ARRAYSIZE(Buttons
);
294 InitCommonControls();
296 /* Create trackbar */
297 hTrackBar
= CreateWindowEx(0,
300 TBS_ENABLESELRANGE
| WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
| WS_CLIPSIBLINGS
,
311 ShowLastWin32Error(hwnd
);
316 hToolBar
= CreateWindowEx(0,
319 WS_CHILD
| WS_VISIBLE
| WS_TABSTOP
| WS_CLIPSIBLINGS
|
320 TBSTYLE_FLAT
| CCS_BOTTOM
| TBSTYLE_TOOLTIPS
,
331 ShowLastWin32Error(hwnd
);
335 hTimeDisplay
= CreateWindowEx(0,
338 WS_CHILD
| WS_VISIBLE
| SS_CENTER
| SS_SUNKEN
,
349 ShowLastWin32Error(hwnd
);
354 SendMessage(hToolBar
, TB_ADDBUTTONS
, NumButtons
, (LPARAM
)Buttons
);
358 SwitchViewMode(HWND hwnd
)
361 MCI_DGV_RECT_PARMS mciVideoRect
;
362 MCI_DGV_WINDOW_PARMSW mciVideoWindow
;
366 mciVideoWindow
.hWnd
= hwnd
;
368 mciError
= mciSendCommand(wDeviceId
, MCI_WINDOW
, MCI_DGV_WINDOW_HWND
| MCI_TEST
, (DWORD_PTR
)&mciVideoWindow
);
372 mciError
= mciSendCommand(wDeviceId
, MCI_WHERE
, MCI_DGV_WHERE_SOURCE
| MCI_TEST
, (DWORD_PTR
)&mciVideoRect
);
376 if (!bIsSingleWindow
)
378 GetWindowRect(hwnd
, &PrevWindowPos
);
380 SetParent(hTrackBar
, hToolBar
);
382 mciError
= mciSendCommand(wDeviceId
, MCI_WHERE
, MCI_DGV_WHERE_SOURCE
, (DWORD_PTR
)&mciVideoRect
);
385 ShowMCIError(hwnd
, mciError
);
389 GetWindowRect(hToolBar
, &rcToolbarRect
);
390 ResizeClientArea(hwnd
, mciVideoRect
.rc
.right
, mciVideoRect
.rc
.bottom
+ (rcToolbarRect
.bottom
- rcToolbarRect
.top
));
392 mciError
= mciSendCommand(wDeviceId
, MCI_WINDOW
, MCI_DGV_WINDOW_HWND
, (DWORD_PTR
)&mciVideoWindow
);
395 ShowMCIError(hwnd
, mciError
);
399 GetWindowRect(hToolBar
, &rcTempRect
);
400 MoveWindow(hTrackBar
, 180, 0, rcTempRect
.right
- rcTempRect
.left
- 322, 25, TRUE
);
401 MoveWindow(hTimeDisplay
, rcTempRect
.right
- rcTempRect
.left
- 140, 4, 135, 18, TRUE
);
403 CheckMenuItem(hMainMenu
, IDM_SWITCHVIEW
, MF_BYCOMMAND
| MF_CHECKED
);
404 bIsSingleWindow
= TRUE
;
408 bIsSingleWindow
= FALSE
;
409 CheckMenuItem(hMainMenu
, IDM_SWITCHVIEW
, MF_BYCOMMAND
| MF_UNCHECKED
);
411 mciVideoWindow
.hWnd
= MCI_DGV_WINDOW_DEFAULT
;
412 mciError
= mciSendCommand(wDeviceId
, MCI_WINDOW
, MCI_DGV_WINDOW_HWND
, (DWORD_PTR
)&mciVideoWindow
);
415 ShowMCIError(hwnd
, mciError
);
419 SetParent(hTrackBar
, hwnd
);
421 MoveWindow(hwnd
, PrevWindowPos
.left
, PrevWindowPos
.top
, PrevWindowPos
.right
- PrevWindowPos
.left
, PrevWindowPos
.bottom
- PrevWindowPos
.top
, TRUE
);
428 MCI_SYSINFO_PARMS mciSysInfo
;
429 DWORD dwNumDevices
= 0;
431 mciSysInfo
.dwCallback
= 0;
432 mciSysInfo
.lpstrReturn
= (LPTSTR
)&dwNumDevices
;
433 mciSysInfo
.dwRetSize
= sizeof(dwNumDevices
);
434 mciSysInfo
.dwNumber
= 0;
435 mciSysInfo
.wDeviceType
= MCI_ALL_DEVICE_ID
;
437 mciSendCommand(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_QUANTITY
, (DWORD_PTR
)&mciSysInfo
);
439 return *(DWORD
*)mciSysInfo
.lpstrReturn
;
443 GetDeviceName(DWORD dwDeviceIndex
, LPTSTR lpDeviceName
, DWORD dwDeviceNameSize
)
445 MCI_SYSINFO_PARMS mciSysInfo
;
447 mciSysInfo
.dwCallback
= 0;
448 mciSysInfo
.lpstrReturn
= lpDeviceName
;
449 mciSysInfo
.dwRetSize
= dwDeviceNameSize
;
450 mciSysInfo
.dwNumber
= dwDeviceIndex
;
451 mciSysInfo
.wDeviceType
= MCI_DEVTYPE_WAVEFORM_AUDIO
;
453 return mciSendCommand(MCI_ALL_DEVICE_ID
, MCI_SYSINFO
, MCI_SYSINFO_NAME
, (DWORD_PTR
)&mciSysInfo
);
457 GetDeviceFriendlyName(LPTSTR lpDeviceName
, LPTSTR lpFriendlyName
, DWORD dwFriendlyNameSize
)
460 MCI_OPEN_PARMS mciOpen
;
461 MCI_INFO_PARMS mciInfo
;
462 MCI_GENERIC_PARMS mciGeneric
;
464 mciOpen
.dwCallback
= 0;
465 mciOpen
.wDeviceID
= 0;
466 mciOpen
.lpstrDeviceType
= lpDeviceName
;
467 mciOpen
.lpstrElementName
= NULL
;
468 mciOpen
.lpstrAlias
= NULL
;
470 mciError
= mciSendCommand(0, MCI_OPEN
, MCI_OPEN_TYPE
| MCI_WAIT
, (DWORD_PTR
)&mciOpen
);
474 mciInfo
.dwCallback
= 0;
475 mciInfo
.lpstrReturn
= lpFriendlyName
;
476 mciInfo
.dwRetSize
= dwFriendlyNameSize
;
478 mciError
= mciSendCommand(mciOpen
.wDeviceID
, MCI_INFO
, MCI_INFO_PRODUCT
, (DWORD_PTR
)&mciInfo
);
480 mciGeneric
.dwCallback
= 0;
481 mciSendCommand(mciOpen
.wDeviceID
, MCI_CLOSE
, MCI_WAIT
, (DWORD_PTR
)&mciGeneric
);
487 DeviceUsesFiles(LPTSTR lpDeviceName
)
490 MCI_OPEN_PARMS mciOpen
;
491 MCI_GETDEVCAPS_PARMS mciDevCaps
;
492 MCI_GENERIC_PARMS mciGeneric
;
494 mciOpen
.dwCallback
= 0;
495 mciOpen
.wDeviceID
= 0;
496 mciOpen
.lpstrDeviceType
= lpDeviceName
;
497 mciOpen
.lpstrElementName
= NULL
;
498 mciOpen
.lpstrAlias
= NULL
;
500 mciError
= mciSendCommand(0, MCI_OPEN
, MCI_OPEN_TYPE
| MCI_WAIT
, (DWORD_PTR
)&mciOpen
);
504 mciDevCaps
.dwCallback
= 0;
505 mciDevCaps
.dwReturn
= 0;
506 mciDevCaps
.dwItem
= MCI_GETDEVCAPS_USES_FILES
;
508 mciError
= mciSendCommand(mciOpen
.wDeviceID
, MCI_GETDEVCAPS
, MCI_WAIT
| MCI_GETDEVCAPS_ITEM
, (DWORD_PTR
)&mciDevCaps
);
512 mciGeneric
.dwCallback
= 0;
513 mciSendCommand(mciOpen
.wDeviceID
, MCI_CLOSE
, MCI_WAIT
, (DWORD_PTR
)&mciGeneric
);
515 return (BOOL
)mciDevCaps
.dwReturn
;
522 MCI_GENERIC_PARMS mciGeneric
;
526 mciError
= mciSendCommand(wDeviceId
, MCI_CLOSE
, MCI_WAIT
, (DWORD_PTR
)&mciGeneric
);
527 if (mciError
!= 0) return mciError
;
531 UpdateTimeDisplay(hTimeDisplay
);
539 OpenMciDevice(HWND hwnd
, LPTSTR lpType
, LPTSTR lpFileName
)
542 MCI_STATUS_PARMS mciStatus
;
543 MCI_OPEN_PARMS mciOpen
;
544 DWORD dwFlags
= MCI_WAIT
;
550 mciOpen
.lpstrDeviceType
= lpType
;
551 mciOpen
.lpstrElementName
= lpFileName
;
552 mciOpen
.dwCallback
= 0;
553 mciOpen
.wDeviceID
= 0;
554 mciOpen
.lpstrAlias
= NULL
;
557 dwFlags
|= MCI_OPEN_TYPE
;
560 dwFlags
|= MCI_OPEN_ELEMENT
;
562 mciError
= mciSendCommand(0, MCI_OPEN
, dwFlags
, (DWORD_PTR
)&mciOpen
);
566 mciStatus
.dwItem
= MCI_STATUS_LENGTH
;
568 mciError
= mciSendCommand(mciOpen
.wDeviceID
, MCI_STATUS
, MCI_STATUS_ITEM
| MCI_WAIT
, (DWORD_PTR
)&mciStatus
);
572 SendMessage(hTrackBar
, TBM_SETRANGEMIN
, (WPARAM
)TRUE
, (LPARAM
)1);
573 SendMessage(hTrackBar
, TBM_SETRANGEMAX
, (WPARAM
)TRUE
, (LPARAM
)mciStatus
.dwReturn
);
574 SendMessage(hTrackBar
, TBM_SETPAGESIZE
, 0, 10);
575 SendMessage(hTrackBar
, TBM_SETLINESIZE
, 0, 1);
576 SendMessage(hTrackBar
, TBM_SETPOS
, (WPARAM
)TRUE
, (LPARAM
)1);
578 if (mciStatus
.dwReturn
< 10000)
580 SendMessage(hTrackBar
, TBM_SETTICFREQ
, (WPARAM
)100, (LPARAM
)0);
582 else if (mciStatus
.dwReturn
< 100000)
584 SendMessage(hTrackBar
, TBM_SETTICFREQ
, (WPARAM
)1000, (LPARAM
)0);
586 else if (mciStatus
.dwReturn
< 1000000)
588 SendMessage(hTrackBar
, TBM_SETTICFREQ
, (WPARAM
)10000, (LPARAM
)0);
592 SendMessage(hTrackBar
, TBM_SETTICFREQ
, (WPARAM
)100000, (LPARAM
)0);
595 MaxFilePos
= mciStatus
.dwReturn
;
596 wDeviceId
= mciOpen
.wDeviceID
;
598 /* NOTE: Everything above this line may be done instead in OpenMediaFile() */
602 lpStr
= _tcsrchr(lpFileName
, _T('\\'));
603 if (lpStr
) // Get only the file name (skip the last path separator)
611 StringCbCopy(szCurrentFile
, sizeof(szCurrentFile
), lpStr
);
613 EnableMenuItems(hwnd
);
615 UpdateTimeDisplay(hTimeDisplay
);
616 UpdateWindowCaption(hwnd
);
622 GetDeviceMode(HWND hwnd
)
625 MCI_STATUS_PARMS mciStatus
;
627 mciStatus
.dwItem
= MCI_STATUS_MODE
;
628 mciError
= mciSendCommand(wDeviceId
, MCI_STATUS
, MCI_WAIT
| MCI_STATUS_ITEM
, (DWORD_PTR
)&mciStatus
);
631 ShowMCIError(hwnd
, mciError
);
632 return MCI_MODE_NOT_READY
;
635 return mciStatus
.dwReturn
;
639 StopPlayback(HWND hwnd
)
642 MCI_GENERIC_PARMS mciGeneric
;
643 MCI_SEEK_PARMS mciSeek
;
645 if (wDeviceId
== 0) return;
647 KillTimer(hwnd
, IDT_PLAYTIMER
);
648 SendMessage(hTrackBar
, TBM_SETPOS
, (WPARAM
)TRUE
, (LPARAM
)1);
650 mciGeneric
.dwCallback
= (DWORD_PTR
)hwnd
;
651 mciError
= mciSendCommand(wDeviceId
, MCI_STOP
, MCI_WAIT
, (DWORD_PTR
)&mciGeneric
);
654 ShowMCIError(hwnd
, mciError
);
658 mciSendCommand(wDeviceId
, MCI_SEEK
, MCI_WAIT
| MCI_SEEK_TO_START
, (DWORD_PTR
)&mciSeek
);
660 UpdateTimeDisplay(hTimeDisplay
);
661 UpdateWindowCaption(hwnd
);
663 SendMessage(hToolBar
,
667 SendMessage(hToolBar
,
670 IDB_PLAYICON
- IDB_PLAYICON
);
674 SeekPlayback(HWND hwnd
, DWORD dwNewPos
)
677 MCI_SEEK_PARMS mciSeek
;
678 MCI_PLAY_PARMS mciPlay
;
680 if (wDeviceId
== 0) return;
682 mciSeek
.dwTo
= (DWORD_PTR
)dwNewPos
;
683 mciError
= mciSendCommand(wDeviceId
, MCI_SEEK
, MCI_WAIT
| MCI_TO
, (DWORD_PTR
)&mciSeek
);
686 ShowMCIError(hwnd
, mciError
);
689 mciPlay
.dwCallback
= (DWORD_PTR
)hwnd
;
690 mciError
= mciSendCommand(wDeviceId
, MCI_PLAY
, MCI_NOTIFY
, (DWORD_PTR
)&mciPlay
);
693 ShowMCIError(hwnd
, mciError
);
698 SeekBackPlayback(HWND hwnd
)
700 MCI_STATUS_PARMS mciStatus
;
703 if (wDeviceId
== 0) return;
705 mciStatus
.dwItem
= MCI_STATUS_POSITION
;
706 mciSendCommand(wDeviceId
, MCI_STATUS
, MCI_STATUS_ITEM
, (DWORD_PTR
)&mciStatus
);
708 dwNewPos
= mciStatus
.dwReturn
- 1;
710 if ((UINT
)dwNewPos
<= 1)
716 SeekPlayback(hwnd
, dwNewPos
);
721 SeekForwPlayback(HWND hwnd
)
723 MCI_STATUS_PARMS mciStatus
;
726 if (wDeviceId
== 0) return;
728 mciStatus
.dwItem
= MCI_STATUS_POSITION
;
729 mciSendCommand(wDeviceId
, MCI_STATUS
, MCI_STATUS_ITEM
, (DWORD_PTR
)&mciStatus
);
731 dwNewPos
= mciStatus
.dwReturn
+ 1;
733 if ((UINT
)dwNewPos
>= MaxFilePos
)
739 SeekPlayback(hwnd
, dwNewPos
);
744 PlayTimerProc(HWND hwnd
, UINT uMsg
, UINT_PTR idEvent
, DWORD dwTime
)
746 MCI_STATUS_PARMS mciStatus
;
749 if (wDeviceId
== 0) KillTimer(hwnd
, IDT_PLAYTIMER
);
751 mciStatus
.dwItem
= MCI_STATUS_POSITION
;
752 mciSendCommand(wDeviceId
, MCI_STATUS
, MCI_STATUS_ITEM
, (DWORD_PTR
)&mciStatus
);
753 dwPos
= mciStatus
.dwReturn
;
755 SendMessage(hTrackBar
, TBM_SETPOS
, (WPARAM
)TRUE
, (LPARAM
)dwPos
);
756 UpdateTimeDisplay(hTimeDisplay
);
760 StartPlayback(HWND hwnd
)
763 MCI_PLAY_PARMS mciPlay
;
764 MCI_SEEK_PARMS mciSeek
;
766 SetTimer(hwnd
, IDT_PLAYTIMER
, 100, (TIMERPROC
)PlayTimerProc
);
768 mciSendCommand(wDeviceId
, MCI_SEEK
, MCI_WAIT
| MCI_SEEK_TO_START
, (DWORD_PTR
)&mciSeek
);
770 mciPlay
.dwCallback
= (DWORD_PTR
)hwnd
;
772 mciPlay
.dwTo
= MaxFilePos
;
774 mciError
= mciSendCommand(wDeviceId
, MCI_PLAY
, MCI_NOTIFY
| MCI_FROM
/*| MCI_TO*/, (DWORD_PTR
)&mciPlay
);
777 ShowMCIError(hwnd
, mciError
);
781 UpdateWindowCaption(hwnd
);
783 SendMessage(hToolBar
,
787 SendMessage(hToolBar
,
790 IDB_PAUSEICON
- IDB_PLAYICON
);
794 TogglePlaybackState(HWND hwnd
)
797 MCI_GENERIC_PARMS mciGeneric
;
798 ULONG idBmp
= IDB_PLAYICON
;
799 ULONG idCmd
= IDC_PLAY
;
801 if (wDeviceId
== 0) return;
803 switch (GetDeviceMode(hwnd
))
814 mciGeneric
.dwCallback
= (DWORD_PTR
)hwnd
;
815 mciError
= mciSendCommand(wDeviceId
, MCI_PAUSE
, MCI_WAIT
, (DWORD_PTR
)&mciGeneric
);
816 idBmp
= IDB_PLAYICON
;
823 mciGeneric
.dwCallback
= (DWORD_PTR
)hwnd
;
824 mciError
= mciSendCommand(wDeviceId
, MCI_RESUME
, MCI_WAIT
, (DWORD_PTR
)&mciGeneric
);
825 idBmp
= IDB_PAUSEICON
;
838 ShowMCIError(hwnd
, mciError
);
842 UpdateWindowCaption(hwnd
);
844 SendMessage(hToolBar
,
848 SendMessage(hToolBar
,
851 idBmp
- IDB_PLAYICON
);
855 ShowDeviceProperties(HWND hwnd
)
858 MCI_GENERIC_PARMS mciGeneric
;
860 mciError
= mciSendCommand(wDeviceId
, MCI_CONFIGURE
, MCI_WAIT
, (DWORD_PTR
)&mciGeneric
);
863 ShowMCIError(hwnd
, mciError
);
868 CloseMediaFile(HWND hwnd
)
873 SwitchViewMode(hwnd
);
876 UpdateWindowCaption(hwnd
);
880 OpenMediaFile(HWND hwnd
, LPTSTR lpFileName
, LPTSTR lpType
)
884 if (GetFileAttributes(lpFileName
) == INVALID_FILE_ATTRIBUTES
)
888 CloseMediaFile(hwnd
);
890 mciError
= OpenMciDevice(hwnd
, lpType
, lpFileName
);
893 ShowMCIError(hwnd
, mciError
);
901 InsertDeviceMenuItem(HMENU hMenu
, UINT uItem
, BOOL fByPosition
, UINT uItemID
, DWORD dwDeviceIndex
)
905 TCHAR szDeviceName
[MAX_MCISTR
];
906 TCHAR szFriendlyName
[MAX_MCISTR
];
908 mciError
= GetDeviceName(dwDeviceIndex
, szDeviceName
, sizeof(szDeviceName
));
914 mciError
= GetDeviceFriendlyName(szDeviceName
, szFriendlyName
, sizeof(szFriendlyName
));
920 if (DeviceUsesFiles(szDeviceName
))
922 StringCbCat(szFriendlyName
, sizeof(szFriendlyName
), _T("..."));
925 ZeroMemory(&lpmii
, sizeof(MENUITEMINFO
));
926 lpmii
.cbSize
= sizeof(lpmii
);
927 lpmii
.fMask
= MIIM_DATA
| MIIM_TYPE
| MIIM_ID
;
929 lpmii
.fType
= MF_STRING
;
930 lpmii
.dwTypeData
= szFriendlyName
;
931 lpmii
.dwItemData
= dwDeviceIndex
;
932 InsertMenuItem(hMenu
, uItem
, fByPosition
, &lpmii
);
938 BuildFileFilterAndDeviceMenu(VOID
)
940 TCHAR szDeviceName
[MAX_MCISTR
];
941 TCHAR szFriendlyName
[MAX_MCISTR
];
942 TCHAR
*szDevice
= NULL
;
943 static TCHAR szDefaultExtension
[] = _T("*.*");
944 TCHAR
*szExtensionList
= NULL
;
945 TCHAR
*szExtension
= NULL
;
950 DWORD dwValueNameLen
;
951 DWORD dwValueDataSize
;
955 DWORD dwExtensionLen
;
956 DWORD dwPosition
= 0;
963 /* Always load the default (all files) filter */
964 LoadString(hInstance
, IDS_ALL_TYPES_FILTER
, szDefaultFilter
, ARRAYSIZE(szDefaultFilter
));
966 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE
, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\MCI Extensions"), 0, KEY_READ
, &hKey
) != ERROR_SUCCESS
)
971 if (RegQueryInfoKey(hKey
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, &dwNumValues
, &dwValueNameLen
, &dwValueDataSize
, NULL
, NULL
) != ERROR_SUCCESS
)
976 dwMaskLen
= ((dwValueNameLen
+ 3) * dwNumValues
) + 1;
978 szExtensionList
= malloc(dwMaskLen
* sizeof(TCHAR
));
979 if (!szExtensionList
)
982 dwNumDevices
= GetNumDevices();
984 /* Allocate space for every pair of Device and Extension Filter */
985 dwFilterSize
= (MAX_MCISTR
+ (dwMaskLen
* 2) + 5) * dwNumDevices
;
987 /* Add space for the "All supported" entry */
988 dwFilterSize
= (dwFilterSize
+ (dwMaskLen
* 2) + 7) * sizeof(TCHAR
) + sizeof(szDefaultFilter
);
990 szFilter
= malloc(dwFilterSize
);
994 szExtension
= malloc((dwValueNameLen
+ 1) * sizeof(TCHAR
));
998 szDevice
= malloc(dwValueDataSize
+ sizeof(TCHAR
));
1002 ZeroMemory(szFilter
, dwFilterSize
);
1004 uSizeRemain
= dwFilterSize
;
1007 for (j
= 1; j
<= dwNumDevices
; j
++)
1009 if (GetDeviceName(j
, szDeviceName
, sizeof(szDeviceName
)))
1014 if (GetDeviceFriendlyName(szDeviceName
, szFriendlyName
, sizeof(szFriendlyName
)))
1019 /* Insert a menu item under the "Device" menu for every found MCI device */
1020 InsertDeviceMenuItem(GetSubMenu(hMainMenu
, 3), dwPosition
, TRUE
, IDM_DEVICE_FIRST
+ dwPosition
, j
);
1023 /* Copy the default extension list, that may be overwritten after... */
1024 StringCbCopy(szExtensionList
, dwMaskLen
* sizeof(TCHAR
), szDefaultExtension
);
1026 /* Try to determine the real extension list */
1027 uMaskRemain
= dwMaskLen
* sizeof(TCHAR
);
1028 d
= szExtensionList
;
1030 for (i
= 0; i
< dwNumValues
; i
++)
1032 dwExtensionLen
= dwValueNameLen
+ 1;
1033 dwDeviceSize
= dwValueDataSize
+ sizeof(TCHAR
);
1035 ZeroMemory(szDevice
, dwDeviceSize
);
1037 if (RegEnumValue(hKey
, i
, szExtension
, &dwExtensionLen
, NULL
, NULL
, (LPBYTE
)szDevice
, &dwDeviceSize
) == ERROR_SUCCESS
)
1039 CharLowerBuff(szDevice
, dwDeviceSize
/ sizeof(TCHAR
));
1040 CharLowerBuff(szDeviceName
, ARRAYSIZE(szDeviceName
));
1041 if (_tcscmp(szDeviceName
, szDevice
) == 0)
1043 CharLowerBuff(szExtension
, dwExtensionLen
);
1044 StringCbPrintfEx(d
, uMaskRemain
, &d
, &uMaskRemain
, 0, _T("%s%s%s"), _T("*."), szExtension
, _T(";"));
1049 /* Remove the last separator */
1051 uSizeRemain
+= sizeof(*d
);
1054 /* Add the description */
1055 StringCbPrintfEx(c
, uSizeRemain
, &c
, &uSizeRemain
, 0, _T("%s (%s)"), szFriendlyName
, szExtensionList
);
1057 /* Skip one char to seperate the description from the filter mask */
1059 uSizeRemain
-= sizeof(*c
);
1061 /* Append the filter mask */
1062 StringCbCopyEx(c
, uSizeRemain
, szExtensionList
, &c
, &uSizeRemain
, 0);
1064 /* Skip another char to seperate the elements of the filter mask */
1066 uSizeRemain
-= sizeof(*c
);
1069 /* Build the full list of supported extensions */
1070 uMaskRemain
= dwMaskLen
* sizeof(TCHAR
);
1071 d
= szExtensionList
;
1073 for (i
= 0; i
< dwNumValues
; i
++)
1075 dwExtensionLen
= dwValueNameLen
+ 1;
1077 if (RegEnumValue(hKey
, i
, szExtension
, &dwExtensionLen
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
)
1079 CharLowerBuff(szExtension
, dwExtensionLen
);
1080 StringCbPrintfEx(d
, uMaskRemain
, &d
, &uMaskRemain
, 0, _T("%s%s%s"), _T("*."), szExtension
, _T(";"));
1084 /* Remove the last separator */
1086 uSizeRemain
+= sizeof(*d
);
1089 /* Add the default (all files) description */
1090 StringCbPrintfEx(c
, uSizeRemain
, &c
, &uSizeRemain
, 0, _T("%s (%s)"), szDefaultFilter
, szExtensionList
);
1092 /* Skip one char to seperate the description from the filter mask */
1094 uSizeRemain
-= sizeof(*c
);
1096 /* Append the filter mask */
1097 StringCbCopyEx(c
, uSizeRemain
, szExtensionList
, &c
, &uSizeRemain
, 0);
1100 if (szExtensionList
) free(szExtensionList
);
1101 if (szExtension
) free(szExtension
);
1102 if (szDevice
) free(szDevice
);
1108 /* We failed at retrieving the supported files, so use the default filter */
1109 if (szFilter
) free(szFilter
);
1110 szFilter
= szDefaultFilter
;
1112 uSizeRemain
= sizeof(szDefaultFilter
);
1115 /* Add the default (all files) description */
1116 StringCbPrintfEx(c
, uSizeRemain
, &c
, &uSizeRemain
, 0, _T("%s (%s)"), szDefaultFilter
, szDefaultExtension
);
1118 /* Skip one char to seperate the description from the filter mask */
1120 uSizeRemain
-= sizeof(*c
);
1122 /* Append the filter mask */
1123 StringCbCopyEx(c
, uSizeRemain
, szDefaultExtension
, &c
, &uSizeRemain
, 0);
1129 CleanupFileFilter(VOID
)
1131 if (szFilter
&& szFilter
!= szDefaultFilter
) free(szFilter
);
1135 OpenFileDialog(HWND hwnd
, DWORD dwFilterIndex
, LPTSTR lpType
)
1137 OPENFILENAME OpenFileName
;
1138 TCHAR szFile
[MAX_PATH
+ 1] = _T("");
1139 TCHAR szCurrentDir
[MAX_PATH
];
1141 ZeroMemory(&OpenFileName
, sizeof(OpenFileName
));
1143 if (!GetCurrentDirectory(ARRAYSIZE(szCurrentDir
), szCurrentDir
))
1145 StringCbCopy(szCurrentDir
, sizeof(szCurrentDir
), _T("c:\\"));
1148 OpenFileName
.lStructSize
= sizeof(OpenFileName
);
1149 OpenFileName
.hwndOwner
= hwnd
;
1150 OpenFileName
.hInstance
= hInstance
;
1151 OpenFileName
.lpstrFilter
= szFilter
;
1152 OpenFileName
.lpstrFile
= szFile
;
1153 OpenFileName
.nMaxFile
= ARRAYSIZE(szFile
);
1154 OpenFileName
.lpstrInitialDir
= szCurrentDir
;
1155 OpenFileName
.Flags
= OFN_FILEMUSTEXIST
| OFN_PATHMUSTEXIST
| OFN_HIDEREADONLY
| OFN_SHAREAWARE
;
1156 OpenFileName
.lpstrDefExt
= _T("\0");
1157 OpenFileName
.nFilterIndex
= dwFilterIndex
;
1159 if (!GetOpenFileName(&OpenFileName
))
1162 OpenMediaFile(hwnd
, OpenFileName
.lpstrFile
, lpType
);
1166 HandleDeviceMenuItem(HWND hwnd
, UINT uItem
)
1169 TCHAR szDeviceName
[MAX_MCISTR
];
1172 ZeroMemory(&lpmii
, sizeof(MENUITEMINFO
));
1173 lpmii
.cbSize
= sizeof(lpmii
);
1174 lpmii
.fMask
= MIIM_DATA
;
1175 GetMenuItemInfo(hMainMenu
, uItem
, FALSE
, &lpmii
);
1177 mciError
= GetDeviceName(lpmii
.dwItemData
, szDeviceName
, sizeof(szDeviceName
));
1180 ShowMCIError(hwnd
, mciError
);
1184 if (DeviceUsesFiles(szDeviceName
))
1186 OpenFileDialog(hwnd
, uItem
- IDM_DEVICE_FIRST
+ 1, szDeviceName
);
1190 mciError
= OpenMciDevice(hwnd
, szDeviceName
, NULL
);
1193 ShowMCIError(hwnd
, mciError
);
1200 MainWndProc(HWND hwnd
, UINT Message
, WPARAM wParam
, LPARAM lParam
)
1207 hMainMenu
= GetMenu(hwnd
);
1214 TCHAR droppedfile
[MAX_PATH
];
1216 drophandle
= (HDROP
)wParam
;
1217 DragQueryFile(drophandle
, 0, droppedfile
, ARRAYSIZE(droppedfile
));
1218 DragFinish(drophandle
);
1219 OpenMediaFile(hwnd
, droppedfile
, NULL
);
1225 if (wParam
== MCI_NOTIFY_SUCCESSFUL
)
1230 StartPlayback(hwnd
);
1238 LPNMHDR pnmhdr
= (LPNMHDR
)lParam
;
1240 switch (pnmhdr
->code
)
1242 case TTN_GETDISPINFO
:
1244 LPTOOLTIPTEXT lpttt
= (LPTOOLTIPTEXT
)lParam
;
1245 UINT idButton
= (UINT
)lpttt
->hdr
.idFrom
;
1250 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_PLAY
);
1253 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_STOP
);
1256 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_EJECT
);
1259 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_BACKWARD
);
1262 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_SEEKBACK
);
1265 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_SEEKFORW
);
1268 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_FORWARD
);
1271 lpttt
->lpszText
= MAKEINTRESOURCE(IDS_TOOLTIP_PAUSE
);
1282 LPRECT pRect
= (LPRECT
)lParam
;
1284 if (!bIsSingleWindow
)
1286 if (pRect
->right
- pRect
->left
< MAIN_WINDOW_MIN_WIDTH
)
1287 pRect
->right
= pRect
->left
+ MAIN_WINDOW_MIN_WIDTH
;
1289 if (pRect
->bottom
- pRect
->top
!= MAIN_WINDOW_HEIGHT
)
1290 pRect
->bottom
= pRect
->top
+ MAIN_WINDOW_HEIGHT
;
1299 if (hToolBar
&& hTrackBar
)
1301 SendMessage(hToolBar
, TB_AUTOSIZE
, 0, 0);
1302 SendMessage(hToolBar
, TB_GETITEMRECT
, 1, (LPARAM
)&Rect
);
1303 MoveWindow(hTimeDisplay
, LOWORD(lParam
) - 140, 4, 135, 18, TRUE
);
1305 if (!bIsSingleWindow
)
1307 UINT Size
= GetSystemMetrics(SM_CYMENU
) + Rect
.bottom
;
1308 MoveWindow(hTrackBar
, 0, 0, LOWORD(lParam
), HIWORD(lParam
) - Size
, TRUE
);
1313 MCI_DGV_PUT_PARMS mciPut
;
1315 MoveWindow(hTrackBar
, 180, 0, LOWORD(lParam
) - 322, 25, TRUE
);
1317 GetClientRect(hwnd
, &Rect
);
1318 GetClientRect(hToolBar
, &ToolbarRect
);
1322 mciPut
.rc
.right
= Rect
.right
;
1323 mciPut
.rc
.bottom
= Rect
.bottom
- (ToolbarRect
.bottom
- ToolbarRect
.top
) - 2;
1325 mciSendCommand(wDeviceId
, MCI_PUT
, MCI_DGV_PUT_DESTINATION
| MCI_DGV_RECT
| MCI_WAIT
, (DWORD_PTR
)&mciPut
);
1333 if (hTrackBar
== (HWND
)lParam
)
1337 DWORD dwNewPos
= (DWORD
)SendMessage(hTrackBar
, TBM_GETPOS
, 0, 0);
1338 SeekPlayback(hwnd
, dwNewPos
);
1342 SendMessage(hTrackBar
, TBM_SETPOS
, TRUE
, 0);
1348 case WM_NCLBUTTONDBLCLK
:
1350 if (wParam
== HTCAPTION
)
1352 SwitchViewMode(hwnd
);
1359 if (LOWORD(wParam
) >= IDM_DEVICE_FIRST
)
1361 HandleDeviceMenuItem(hwnd
, LOWORD(wParam
));
1365 switch (LOWORD(wParam
))
1371 TogglePlaybackState(hwnd
);
1373 OpenFileDialog(hwnd
, 1, NULL
);
1389 SeekBackPlayback(hwnd
);
1393 SeekForwPlayback(hwnd
);
1400 OpenFileDialog(hwnd
, 1, NULL
);
1403 case IDM_CLOSE_FILE
:
1404 CloseMediaFile(hwnd
);
1411 CheckMenuItem(hMainMenu
, IDM_REPEAT
, MF_BYCOMMAND
| MF_CHECKED
);
1416 CheckMenuItem(hMainMenu
, IDM_REPEAT
, MF_BYCOMMAND
| MF_UNCHECKED
);
1422 case IDM_SWITCHVIEW
:
1423 SwitchViewMode(hwnd
);
1427 ShowDeviceProperties(hwnd
);
1431 ShellExecute(hwnd
, NULL
, _T("SNDVOL32.EXE"), NULL
, NULL
, SW_SHOWNORMAL
);
1436 HICON mplayIcon
= LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_MAIN
));
1437 ShellAbout(hwnd
, szAppTitle
, 0, mplayIcon
);
1438 DeleteObject(mplayIcon
);
1443 PostMessage(hwnd
, WM_CLOSE
, 0, 0);
1450 CloseMediaFile(hwnd
);
1455 return DefWindowProc(hwnd
, Message
, wParam
, lParam
);
1459 _tWinMain(HINSTANCE hInst
, HINSTANCE hPrevInst
, LPTSTR lpCmdLine
, INT nCmdShow
)
1461 WNDCLASSEX WndClass
= {0};
1462 TCHAR szClassName
[] = _T("ROSMPLAY32");
1470 LoadString(hInstance
, IDS_APPTITLE
, szAppTitle
, ARRAYSIZE(szAppTitle
));
1472 WndClass
.cbSize
= sizeof(WndClass
);
1473 WndClass
.lpszClassName
= szClassName
;
1474 WndClass
.lpfnWndProc
= MainWndProc
;
1475 WndClass
.hInstance
= hInstance
;
1476 WndClass
.style
= CS_HREDRAW
| CS_VREDRAW
;
1477 WndClass
.hIcon
= LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_MAIN
));
1478 WndClass
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
1479 WndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
1480 WndClass
.lpszMenuName
= MAKEINTRESOURCE(IDR_MAINMENU
);
1482 if (!RegisterClassEx(&WndClass
))
1484 ShowLastWin32Error(NULL
);
1488 hwnd
= CreateWindow(szClassName
,
1490 WS_SYSMENU
| WS_MINIMIZEBOX
| WS_THICKFRAME
| WS_OVERLAPPED
| WS_CAPTION
| WS_CLIPCHILDREN
,
1501 ShowLastWin32Error(NULL
);
1505 hAccel
= LoadAccelerators(hInstance
, MAKEINTRESOURCE(ID_ACCELERATORS
));
1507 BuildFileFilterAndDeviceMenu();
1509 DragAcceptFiles(hwnd
, TRUE
);
1513 dwError
= SearchPath(NULL
, _T("SNDVOL32.EXE"), NULL
, 0, NULL
, NULL
);
1516 EnableMenuItem(hMainMenu
, IDM_VOLUMECTL
, MF_BYCOMMAND
| MF_GRAYED
);
1520 ShowWindow(hwnd
, SW_SHOW
);
1523 OpenMediaFile(hwnd
, lpCmdLine
, NULL
);
1526 while (GetMessage(&msg
, NULL
, 0, 0))
1528 if (!TranslateAccelerator(hwnd
, hAccel
, &msg
))
1530 TranslateMessage(&msg
);
1531 DispatchMessage(&msg
);
1535 CleanupFileFilter();
1537 DestroyAcceleratorTable(hAccel
);
1539 return (INT
)msg
.wParam
;