ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

mplay32.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:         ReactOS Multimedia Player
00003  * FILE:            base\applications\mplay32\mplay32.c
00004  * PROGRAMMERS:     Dmitry Chapyshev (dmitry@reactos.org)
00005  */
00006 
00007 #include "mplay32.h"
00008 
00009 #define MAIN_WINDOW_HEIGHT    125
00010 #define MAIN_WINDOW_MIN_WIDTH 250
00011 
00012 HINSTANCE hInstance = NULL;
00013 HWND hTrackBar = NULL;
00014 HWND hToolBar = NULL;
00015 TCHAR szAppTitle[256] = _T("");
00016 TCHAR szPrevFile[MAX_PATH] = _T("\0");
00017 WORD wDeviceId;
00018 BOOL bIsOpened = FALSE;
00019 BOOL bIsPaused = FALSE;
00020 UINT MaxFilePos = 0;
00021 
00022 /* Known types table */
00023 static const TYPEBYEXT ExtTypes[] =
00024 {
00025     { _T(".wav"),  WAVE_FILE    },
00026     { _T(".wave"), WAVE_FILE    },
00027     { _T(".mid"),  MIDI_FILE    },
00028     { _T(".midi"), MIDI_FILE    },
00029     { _T(".cda"),  AUDIOCD_FILE },
00030     { _T(".avi"),  AVI_FILE     },
00031     { _T("\0"),        0        }
00032 };
00033 
00034 /* ToolBar Buttons */
00035 static const TBBUTTON Buttons[] =
00036 {   /* iBitmap,        idCommand,    fsState,         fsStyle,     bReserved[2], dwData, iString */
00037     {TBICON_PLAY,      IDC_PLAY,     TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
00038     {TBICON_STOP,      IDC_STOP,     TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
00039     {TBICON_EJECT,     IDC_EJECT,    TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
00040     {15,               0,            TBSTATE_ENABLED, BTNS_SEP,    {0}, 0, 0},
00041     {TBICON_BACKWARD,  IDC_BACKWARD, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
00042     {TBICON_SEEKBACK,  IDC_SEEKBACK, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
00043     {TBICON_SEEKFORW,  IDC_SEEKFORW, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
00044     {TBICON_FORWARD,   IDC_FORWARD,  TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}
00045 };
00046 
00047 static VOID
00048 SetImageList(HWND hwnd)
00049 {
00050     HIMAGELIST hImageList;
00051 
00052     hImageList = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR24, 1, 1);
00053 
00054     if (!hImageList)
00055     {
00056         MessageBox(hwnd, _T("ImageList it is not created!"), NULL, MB_OK);
00057         return;
00058     }
00059 
00060     ImageList_AddMasked(hImageList,
00061                         LoadImage(hInstance, MAKEINTRESOURCE(IDB_PLAYICON), IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR),
00062                         RGB(255, 255, 255));
00063 
00064     ImageList_AddMasked(hImageList,
00065                         LoadImage(hInstance, MAKEINTRESOURCE(IDB_STOPICON), IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR),
00066                         RGB(255, 255, 255));
00067 
00068     ImageList_AddMasked(hImageList,
00069                         LoadImage(hInstance, MAKEINTRESOURCE(IDB_EJECTICON), IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR),
00070                         RGB(255, 255, 255));
00071 
00072     ImageList_AddMasked(hImageList,
00073                         LoadImage(hInstance, MAKEINTRESOURCE(IDB_BACKWARDICON), IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR),
00074                         RGB(255, 255, 255));
00075 
00076     ImageList_AddMasked(hImageList,
00077                         LoadImage(hInstance, MAKEINTRESOURCE(IDB_SEEKBACKICON), IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR),
00078                         RGB(255, 255, 255));
00079 
00080     ImageList_AddMasked(hImageList,
00081                         LoadImage(hInstance, MAKEINTRESOURCE(IDB_SEEKFORWICON), IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR),
00082                         RGB(255, 255, 255));
00083 
00084     ImageList_AddMasked(hImageList,
00085                         LoadImage(hInstance, MAKEINTRESOURCE(IDB_FORWARDICON), IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR),
00086                         RGB(255, 255, 255));
00087 
00088     ImageList_Destroy((HIMAGELIST)SendMessage(hToolBar,
00089                                               TB_SETIMAGELIST,
00090                                               0,
00091                                               (LPARAM)hImageList));
00092 }
00093 
00094 static VOID
00095 InitControls(HWND hwnd)
00096 {
00097     INT NumButtons = sizeof(Buttons) / sizeof(Buttons[0]);
00098 
00099     InitCommonControls();
00100 
00101     /* Create trackbar */
00102     hTrackBar = CreateWindowEx(0,
00103                                TRACKBAR_CLASS,
00104                                NULL,
00105                                TBS_ENABLESELRANGE | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_CLIPSIBLINGS,
00106                                0,
00107                                0,
00108                                340,
00109                                20,
00110                                hwnd,
00111                                NULL,
00112                                hInstance,
00113                                NULL);
00114     if (!hTrackBar)
00115     {
00116         MessageBox(hwnd, _T("TrackBar it is not created!"), NULL, MB_OK);
00117         return;
00118     }
00119 
00120     /* Create toolbar */
00121     hToolBar = CreateWindowEx(0,
00122                               TOOLBARCLASSNAME,
00123                               NULL,
00124                               WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_CLIPSIBLINGS |
00125                               TBSTYLE_FLAT | CCS_BOTTOM | TBSTYLE_TOOLTIPS,
00126                               0,
00127                               40,
00128                               340,
00129                               30,
00130                               hwnd,
00131                               NULL,
00132                               hInstance,
00133                               NULL);
00134     if (!hToolBar)
00135     {
00136         MessageBox(hwnd, _T("ToolBar it is not created!"), NULL, MB_OK);
00137         return;
00138     }
00139 
00140     SetImageList(hwnd);
00141     SendMessage(hToolBar, TB_ADDBUTTONS, NumButtons, (LPARAM)Buttons);
00142 }
00143 
00144 static UINT
00145 IsSupportedFileExtension(LPTSTR lpFileName)
00146 {
00147     TCHAR szExt[MAX_PATH];
00148     INT DotPos = 0, i, j;
00149 
00150     for (i = _tcslen(lpFileName); i >= 0; --i)
00151     {
00152         if (lpFileName[i] == '.')
00153         {
00154             DotPos = _tcslen(lpFileName) - i;
00155             break;
00156         }
00157     }
00158 
00159     if (!DotPos) return UNSUPPORTED_FILE;
00160 
00161     szExt[DotPos + 1] = _T('\0');
00162     for (i = _tcslen(lpFileName), j = DotPos; j >= 0; --i, --j)
00163     {
00164         szExt[j] = lpFileName[i];
00165     }
00166 
00167     for (i = 0; ; i++)
00168     {
00169         if (ExtTypes[i].uType == UNSUPPORTED_FILE)
00170         {
00171             return UNSUPPORTED_FILE;
00172         }
00173 
00174         if (_tcscmp(ExtTypes[i].szExt, szExt) == 0)
00175         {
00176             return ExtTypes[i].uType;
00177         }
00178     }
00179 
00180     return UNSUPPORTED_FILE;
00181 }
00182 
00183 static DWORD
00184 CloseMciDevice(VOID)
00185 {
00186     MCI_GENERIC_PARMS mciGeneric;
00187     DWORD dwError;
00188 
00189     if (bIsOpened)
00190     {
00191         dwError = mciSendCommand(wDeviceId, MCI_CLOSE, MCI_WAIT, (DWORD_PTR)&mciGeneric);
00192         if (dwError) return dwError;
00193         bIsOpened = FALSE;
00194     }
00195 
00196     return TRUE;
00197 }
00198 
00199 static DWORD
00200 OpenMciDevice(HWND hwnd, LPTSTR lpType, LPTSTR lpFileName)
00201 {
00202     MCI_STATUS_PARMS mciStatus;
00203     MCI_OPEN_PARMS mciOpen;
00204     TCHAR szNewTitle[MAX_PATH];
00205     DWORD dwError;
00206 
00207     if (bIsOpened)
00208     {
00209         CloseMciDevice();
00210     }
00211 
00212     mciOpen.lpstrDeviceType = lpType;
00213     mciOpen.lpstrElementName = lpFileName;
00214     mciOpen.dwCallback = 0;
00215     mciOpen.wDeviceID = 0;
00216     mciOpen.lpstrAlias = NULL;
00217 
00218     dwError = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT | MCI_WAIT, (DWORD_PTR)&mciOpen);
00219     if (dwError != 0)
00220     {
00221         MessageBox(0, _T("Can't open device! (1)"), NULL, MB_OK);
00222         return dwError;
00223     }
00224 
00225     mciStatus.dwItem = MCI_STATUS_LENGTH;
00226 
00227     dwError = mciSendCommand(mciOpen.wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (DWORD_PTR)&mciStatus);
00228     if (dwError != 0)
00229     {
00230         MessageBox(0, _T("Can't open device! (2)"), NULL, MB_OK);
00231         return dwError;
00232     }
00233 
00234     SendMessage(hTrackBar, TBM_SETRANGE, (WPARAM) TRUE, (LPARAM) MAKELONG(1, mciStatus.dwReturn));
00235     SendMessage(hTrackBar, TBM_SETPAGESIZE, 0, 10);
00236     SendMessage(hTrackBar, TBM_SETLINESIZE, 0, 1);
00237     SendMessage(hTrackBar, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) 1);
00238 
00239     if (mciStatus.dwReturn < 10000)
00240     {
00241         SendMessage(hTrackBar, TBM_SETTICFREQ, (WPARAM) 100, (LPARAM) 0);
00242     }
00243     else if (mciStatus.dwReturn < 100000)
00244     {
00245         SendMessage(hTrackBar, TBM_SETTICFREQ, (WPARAM) 1000, (LPARAM) 0);
00246     }
00247     else if (mciStatus.dwReturn < 1000000)
00248     {
00249         SendMessage(hTrackBar, TBM_SETTICFREQ, (WPARAM) 10000, (LPARAM) 0);
00250     }
00251     else
00252     {
00253         SendMessage(hTrackBar, TBM_SETTICFREQ, (WPARAM) 100000, (LPARAM) 0);
00254     }
00255 
00256     _stprintf(szNewTitle, _T("%s - %s"), szAppTitle, lpFileName);
00257     SetWindowText(hwnd, szNewTitle);
00258 
00259     MaxFilePos = mciStatus.dwReturn;
00260     wDeviceId = mciOpen.wDeviceID;
00261     bIsOpened = TRUE;
00262     _tcscpy(szPrevFile, lpFileName);
00263     return TRUE;
00264 }
00265 
00266 static VOID
00267 StopPlayback(HWND hwnd)
00268 {
00269     if (bIsOpened)
00270     {
00271         SendMessage(hTrackBar, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) 1);
00272         KillTimer(hwnd, IDT_PLAYTIMER);
00273         CloseMciDevice();
00274     }
00275 }
00276 
00277 static VOID
00278 SeekPlayback(HWND hwnd, DWORD dwNewPos)
00279 {
00280     MCI_SEEK_PARMS mciSeek;
00281     MCI_PLAY_PARMS mciPlay;
00282     DWORD dwError;
00283 
00284     if (bIsOpened)
00285     {
00286         mciSeek.dwTo = (DWORD_PTR)dwNewPos;
00287         dwError = mciSendCommand(wDeviceId, MCI_SEEK, MCI_WAIT | MCI_TO, (DWORD_PTR)&mciSeek);
00288         if (dwError != 0)
00289         {
00290             MessageBox(hwnd, _T("SeekPlayback: Can't seek!"), NULL, MB_OK);
00291         }
00292 
00293         mciPlay.dwCallback = (DWORD_PTR)hwnd;
00294         dwError = mciSendCommand(wDeviceId, MCI_PLAY, MCI_NOTIFY, (DWORD_PTR)&mciPlay);
00295         if (dwError != 0)
00296         {
00297             MessageBox(hwnd, _T("SeekPlayback: Can't play!"), NULL, MB_OK);
00298         }
00299     }
00300 }
00301 
00302 static VOID
00303 SeekBackPlayback(HWND hwnd)
00304 {
00305     MCI_STATUS_PARMS mciStatus;
00306     DWORD dwNewPos;
00307 
00308     if (!bIsOpened) return;
00309 
00310     mciStatus.dwItem = MCI_STATUS_POSITION;
00311     mciSendCommand(wDeviceId, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&mciStatus);
00312 
00313     dwNewPos = mciStatus.dwReturn - 1;
00314 
00315     if((UINT)dwNewPos <= 1)
00316     {
00317         StopPlayback(hwnd);
00318     }
00319     else
00320     {
00321         SeekPlayback(hwnd, dwNewPos);
00322     }
00323 }
00324 
00325 static VOID
00326 SeekForwPlayback(HWND hwnd)
00327 {
00328     MCI_STATUS_PARMS mciStatus;
00329     DWORD dwNewPos;
00330 
00331     if (!bIsOpened) return;
00332 
00333     mciStatus.dwItem = MCI_STATUS_POSITION;
00334     mciSendCommand(wDeviceId, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&mciStatus);
00335 
00336     dwNewPos = mciStatus.dwReturn + 1;
00337 
00338     if((UINT)dwNewPos >= MaxFilePos)
00339     {
00340         StopPlayback(hwnd);
00341     }
00342     else
00343     {
00344         SeekPlayback(hwnd, dwNewPos);
00345     }
00346 }
00347 
00348 static VOID
00349 PausePlayback(HWND hwnd)
00350 {
00351     MCI_GENERIC_PARMS mciGeneric;
00352     DWORD dwError;
00353 
00354     if (bIsOpened)
00355     {
00356         dwError = mciSendCommand(wDeviceId, MCI_PAUSE, MCI_WAIT, (DWORD_PTR)&mciGeneric);
00357         if (dwError != 0)
00358         {
00359             MessageBox(hwnd, _T("Can't pause!"), NULL, MB_OK);
00360         }
00361         bIsPaused = TRUE;
00362     }
00363 }
00364 
00365 static VOID
00366 ResumePlayback(HWND hwnd)
00367 {
00368     MCI_GENERIC_PARMS mciGeneric;
00369     DWORD dwError;
00370 
00371     if (bIsPaused)
00372     {
00373         dwError = mciSendCommand(wDeviceId, MCI_RESUME, MCI_WAIT, (DWORD_PTR)&mciGeneric);
00374         if (dwError != 0)
00375         {
00376             MessageBox(hwnd, _T("Can't resume!"), NULL, MB_OK);
00377         }
00378         bIsPaused = FALSE;
00379     }
00380 }
00381 
00382 VOID CALLBACK
00383 PlayTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
00384 {
00385     MCI_STATUS_PARMS mciStatus;
00386     DWORD dwPos;
00387 
00388     if (!bIsOpened) KillTimer(hwnd, IDT_PLAYTIMER);
00389 
00390     mciStatus.dwItem = MCI_STATUS_POSITION;
00391     mciSendCommand(wDeviceId, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&mciStatus);
00392     dwPos = mciStatus.dwReturn;
00393 
00394     if((UINT)dwPos >= MaxFilePos)
00395     {
00396         StopPlayback(hwnd);
00397     }
00398     else
00399     {
00400         SendMessage(hTrackBar, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) dwPos);
00401     }
00402 }
00403 
00404 static VOID
00405 PlayFile(HWND hwnd, LPTSTR lpFileName)
00406 {
00407     MCI_PLAY_PARMS mciPlay;
00408     TCHAR szLocalFileName[MAX_PATH];
00409     UINT FileType;
00410     MCIERROR mciError;
00411 
00412     if (lpFileName == NULL)
00413     {
00414         if (szPrevFile[0] == _T('\0'))
00415             return;
00416 
00417         _tcscpy(szLocalFileName, szPrevFile);
00418     }
00419     else
00420     {
00421         _tcscpy(szLocalFileName, lpFileName);
00422     }
00423 
00424     if (GetFileAttributes(szLocalFileName) == INVALID_FILE_ATTRIBUTES)
00425     {
00426         return;
00427     }
00428 
00429     FileType = IsSupportedFileExtension(szLocalFileName);
00430 
00431     switch (FileType)
00432     {
00433         case UNSUPPORTED_FILE:
00434             MessageBox(hwnd, _T("Unsupported format!"), NULL, MB_OK);
00435             return;
00436         case WAVE_FILE:
00437             OpenMciDevice(hwnd, _T("waveaudio"), szLocalFileName);
00438             break;
00439         case MIDI_FILE:
00440             OpenMciDevice(hwnd, _T("sequencer"), szLocalFileName);
00441             break;
00442         case AUDIOCD_FILE:
00443             OpenMciDevice(hwnd, _T("cdaudio"), szLocalFileName);
00444             break;
00445         case AVI_FILE:
00446             OpenMciDevice(hwnd, _T("avivideo"), szLocalFileName);
00447             break;
00448     }
00449 
00450     SetTimer(hwnd, IDT_PLAYTIMER, 100, (TIMERPROC) PlayTimerProc);
00451 
00452     mciSendCommand(wDeviceId, MCI_SEEK, MCI_WAIT | MCI_SEEK_TO_START, 0);
00453 
00454     mciPlay.dwCallback = (DWORD_PTR)hwnd;
00455     mciPlay.dwFrom = 0;
00456     mciPlay.dwTo = MaxFilePos;
00457 
00458     mciError = mciSendCommand(wDeviceId, MCI_PLAY, MCI_NOTIFY | MCI_FROM /*| MCI_TO*/, (DWORD_PTR)&mciPlay);
00459     if (mciError != 0)
00460     {
00461         MessageBox(hwnd, _T("Can't play!"), NULL, MB_OK);
00462     }
00463 }
00464 
00465 static VOID
00466 OpenFileDialog(HWND hwnd)
00467 {
00468     OPENFILENAME OpenFileName;
00469     TCHAR szFile[MAX_PATH + 1] = _T("\0");
00470     TCHAR szFilter[MAX_PATH], szCurrentDir[MAX_PATH];
00471 
00472     ZeroMemory(&OpenFileName, sizeof(OpenFileName));
00473 
00474     LoadString(hInstance, IDS_ALL_TYPES_FILTER, szFilter, sizeof(szFilter) / sizeof(TCHAR));
00475 
00476     if (!GetCurrentDirectory(sizeof(szCurrentDir) / sizeof(TCHAR), szCurrentDir))
00477     {
00478         _tcscpy(szCurrentDir, _T("c:\\"));
00479     }
00480 
00481     OpenFileName.lStructSize     = sizeof(OpenFileName);
00482     OpenFileName.hwndOwner       = hwnd;
00483     OpenFileName.hInstance       = hInstance;
00484     OpenFileName.lpstrFilter     = szFilter;
00485     OpenFileName.lpstrFile       = szFile;
00486     OpenFileName.nMaxFile        = sizeof(szFile) / sizeof((szFile)[0]);
00487     OpenFileName.lpstrInitialDir = szCurrentDir;
00488     OpenFileName.Flags           = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_SHAREAWARE;
00489     OpenFileName.lpstrDefExt     = _T("\0");
00490 
00491     if (GetOpenFileName(&OpenFileName))
00492     {
00493         PlayFile(hwnd, OpenFileName.lpstrFile);
00494     }
00495 }
00496 
00497 LRESULT CALLBACK
00498 MainWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
00499 {
00500     switch (Message)
00501     {
00502         case WM_CREATE:
00503             InitControls(hwnd);
00504             break;
00505 
00506         case WM_NOTIFY:
00507         {
00508             LPNMHDR pnmhdr = (LPNMHDR)lParam;
00509 
00510             switch (pnmhdr->code)
00511             {
00512                 case TTN_GETDISPINFO:
00513                 {
00514                     LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT)lParam;
00515                     UINT idButton = (UINT)lpttt->hdr.idFrom;
00516 
00517                     switch (idButton)
00518                     {
00519                         case IDC_PLAY:
00520                             lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_PLAY);
00521                         break;
00522                         case IDC_STOP:
00523                             lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_STOP);
00524                         break;
00525                         case IDC_EJECT:
00526                             lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_EJECT);
00527                         break;
00528                         case IDC_BACKWARD:
00529                             lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_BACKWARD);
00530                         break;
00531                         case IDC_SEEKBACK:
00532                             lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_SEEKBACK);
00533                         break;
00534                         case IDC_SEEKFORW:
00535                             lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_SEEKFORW);
00536                         break;
00537                         case IDC_FORWARD:
00538                             lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_FORWARD);
00539                         break;
00540                     }
00541                     break;
00542                 }
00543             }
00544         }
00545         break;
00546 
00547         case WM_SIZING:
00548         {
00549             LPRECT pRect = (LPRECT)lParam;
00550 
00551             if (pRect->right - pRect->left < MAIN_WINDOW_MIN_WIDTH)
00552                 pRect->right = pRect->left + MAIN_WINDOW_MIN_WIDTH;
00553 
00554             if (pRect->bottom - pRect->top != MAIN_WINDOW_HEIGHT)
00555                 pRect->bottom = pRect->top + MAIN_WINDOW_HEIGHT;
00556 
00557             return TRUE;
00558         }
00559 
00560         case WM_SIZE:
00561         {
00562             RECT Rect;
00563             UINT Size;
00564 
00565             if (hToolBar && hTrackBar)
00566             {
00567                 SendMessage(hToolBar, TB_AUTOSIZE, 0, 0);
00568                 SendMessage(hToolBar, TB_GETITEMRECT, 1, (LPARAM)&Rect);
00569 
00570                 Size = GetSystemMetrics(SM_CYMENU) + Rect.bottom;
00571                 MoveWindow(hTrackBar, 0, 0, LOWORD(lParam), HIWORD(lParam) - Size, TRUE);
00572             }
00573             return 0L;
00574         }
00575 
00576         case WM_HSCROLL:
00577         {
00578             if (hTrackBar == (HWND) lParam)
00579             {
00580                 if (bIsOpened)
00581                 {
00582                     DWORD dwNewPos = (DWORD) SendMessage(hTrackBar, TBM_GETPOS, 0, 0);
00583                     SeekPlayback(hwnd, dwNewPos);
00584                 }
00585                 else
00586                 {
00587                     SendMessage(hTrackBar, TBM_SETPOS, TRUE, 0);
00588                 }
00589             }
00590         }
00591         break;
00592 
00593         case WM_COMMAND:
00594             switch (LOWORD(wParam))
00595             {
00596                 case IDC_PLAY:
00597                     if (bIsOpened)
00598                     {
00599                         if (bIsPaused)
00600                             ResumePlayback(hwnd);
00601                         else
00602                             PausePlayback(hwnd);
00603                     }
00604                     else
00605                     {
00606                         if (szPrevFile[0] == _T('\0'))
00607                             OpenFileDialog(hwnd);
00608                         else
00609                             PlayFile(hwnd, NULL);
00610                     }
00611                     break;
00612 
00613                 case IDC_STOP:
00614                     StopPlayback(hwnd);
00615                     break;
00616 
00617                 case IDC_EJECT:
00618                     break;
00619 
00620                 case IDC_BACKWARD:
00621                     break;
00622 
00623                 case IDC_SEEKBACK:
00624                     SeekBackPlayback(hwnd);
00625                     break;
00626 
00627                 case IDC_SEEKFORW:
00628                     SeekForwPlayback(hwnd);
00629                     break;
00630 
00631                 case IDC_FORWARD:
00632                     break;
00633 
00634                 case IDM_OPEN_FILE:
00635                     OpenFileDialog(hwnd);
00636                     return 0;
00637 
00638                 case IDM_CLOSE_FILE:
00639                     StopPlayback(hwnd);
00640                     _tcscpy(szPrevFile, _T("\0"));
00641                     break;
00642 
00643                 case IDM_ABOUT:
00644         {
00645                     HICON mplayIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAIN));
00646                     ShellAbout(hwnd, szAppTitle, 0, mplayIcon);
00647             DeleteObject(mplayIcon);
00648                     break;
00649         }
00650                 case IDM_EXIT:
00651                     PostMessage(hwnd, WM_CLOSE, 0, 0);
00652                     return 0;
00653             }
00654             break;
00655 
00656         case WM_DESTROY:
00657             StopPlayback(hwnd);
00658             PostQuitMessage(0);
00659             return 0;
00660     }
00661 
00662     return DefWindowProc(hwnd, Message, wParam, lParam);
00663 }
00664 
00665 INT WINAPI
00666 _tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPTSTR lpCmdLine, INT nCmdShow)
00667 {
00668     WNDCLASSEX WndClass = {0};
00669     TCHAR szClassName[] = _T("ROSMPLAY32");
00670     HWND hwnd;
00671     MSG msg;
00672 
00673     hInstance = hInst;
00674 
00675     LoadString(hInstance, IDS_APPTITLE, szAppTitle, sizeof(szAppTitle) / sizeof(TCHAR));
00676 
00677     WndClass.cbSize            = sizeof(WNDCLASSEX);
00678     WndClass.lpszClassName     = szClassName;
00679     WndClass.lpfnWndProc       = MainWndProc;
00680     WndClass.hInstance         = hInstance;
00681     WndClass.style             = CS_HREDRAW | CS_VREDRAW;
00682     WndClass.hIcon             = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAIN));
00683     WndClass.hCursor           = LoadCursor(NULL, IDC_ARROW);
00684     WndClass.hbrBackground     = (HBRUSH)(COLOR_BTNFACE + 1);
00685     WndClass.lpszMenuName      = MAKEINTRESOURCE(IDR_MAINMENU);
00686 
00687     RegisterClassEx(&WndClass);
00688 
00689     hwnd = CreateWindow(szClassName,
00690                         szAppTitle,
00691                         WS_SYSMENU | WS_MINIMIZEBOX | WS_THICKFRAME | WS_OVERLAPPED | WS_CAPTION | WS_CLIPCHILDREN,
00692                         CW_USEDEFAULT,
00693                         CW_USEDEFAULT,
00694                         350,
00695                         MAIN_WINDOW_HEIGHT,
00696                         NULL,
00697                         NULL,
00698                         hInstance,
00699                         NULL);
00700 
00701     /* Show it */
00702     ShowWindow(hwnd, SW_SHOW);
00703     UpdateWindow(hwnd);
00704 
00705     PlayFile(hwnd, lpCmdLine);
00706 
00707     /* Message Loop */
00708     while (GetMessage(&msg, NULL, 0, 0))
00709     {
00710         TranslateMessage(&msg);
00711         DispatchMessage(&msg);
00712     }
00713 
00714     return 0;
00715 }

Generated on Sat May 26 2012 04:15:51 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.