home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0090 - 0099 / ibm0090-0099 / ibm0099.tar / ibm0099 / ANIW3ECR.ZIP / SAMPLE / AWMCISAM.C next >
Encoding:
C/C++ Source or Header  |  1992-12-28  |  48.5 KB  |  1,663 lines

  1. /*
  2. ==============================================================================
  3.  
  4.     Program:    AWMCISAM
  5.  
  6.     Purpose:    Sample program that utilizies the Gold Disk MCI Animation
  7.                 Driver.
  8.  
  9.     Note:
  10.     Gold Disk does not warrant, guarantee or make any representations
  11.     regarding the use of, or the results of the use of the Sample MCI
  12.     application in terms of correctness, accuracy, reliability, currentness,
  13.     or otherwise; and you rely on the Sample MCI application and results
  14.     solely at your own risk.
  15.  
  16. ==============================================================================
  17. */
  18.  
  19. #include "awmcisam.h"
  20. #include "mciawi_x.h"
  21.  
  22. VOID    msDisplayMCIError (DWORD);
  23. VOID    msSetControlsState (HWND, BOOL);
  24. BOOL    msIsMoviePlaying (VOID);
  25. VOID    msFillWindowColor (HWND, int);
  26. VOID    msSetDlgItemCaps (HWND,DWORD, WORD);
  27.  
  28.  
  29. // If flag is TRUE we play into the driver's default screen otherwise
  30. // we play into the static window within the main dialog
  31. static BOOL bFullScreen;
  32.  
  33. // This is the main instance handle for the app
  34. static HANDLE   hMainInstance;
  35.  
  36. // This holds the device Id of a open MCI element
  37. static WORD wDeviceID = -1;
  38.  
  39. //  main dialog
  40. static HWND hdlgMain;
  41.  
  42. /*****************************************************************************
  43.  
  44.     Function: WinMain ()
  45.  
  46. *****************************************************************************/
  47.  
  48. int PASCAL WinMain (
  49. HANDLE hInstance,                 // current instance
  50. HANDLE hPrevInstance,             // previous instance
  51. LPSTR lpCmdLine,                 // command line
  52. int nCmdShow)                     // show-window type (open/icon)
  53. {
  54.     MSG         msg;
  55.     FARPROC     lpfnMainDlgProc; // Pointer for the Main Dialog Box
  56.     
  57.     hMainInstance = hInstance;
  58.     lpfnMainDlgProc = MakeProcInstance (msMainDlgProc, hMainInstance);
  59.     return DialogBox (hMainInstance, IDDLG_MAIN, NULL, lpfnMainDlgProc);
  60. }
  61.  
  62.  
  63. /*****************************************************************************
  64.  
  65.     Function:   MainWndProc ()          - windows callable
  66.  
  67.     Desc:       Main hidden window; parent of main dialog box.
  68.  
  69. *****************************************************************************/
  70.  
  71. LONG FAR PASCAL MainWndProc (
  72. HWND hwnd,
  73. unsigned message,
  74. WORD wParam,
  75. LONG lParam)
  76. {
  77.     switch (message)
  78.     {
  79.  
  80.     default:
  81.             return (DefWindowProc(hwnd, message, wParam, lParam));
  82.     }
  83.     return (NULL);
  84. }
  85.  
  86.  
  87. /******************************************************************************
  88.  
  89.     Function:    msMainDlgProc ()        - windows callable
  90.  
  91.     Desc:        Dialog procedure for the 'Main' dialog box.
  92.  
  93.     Returns:    BOOL    TRUE            
  94.                         FALSE           
  95.  
  96. ******************************************************************************/
  97.  
  98. BOOL FAR PASCAL
  99. msMainDlgProc (
  100.     HWND        hdlg,
  101.     unsigned    message,
  102.     WORD        wParam,
  103.     LONG        lParam)
  104. {
  105.     // MCI structure that is needed when playing a movie    
  106.     MCI_ANIM_PLAY_PARMS      mciAnimPlayParms;
  107.  
  108.     // MCI structure that is needed when stepping in a movie    
  109.     MCI_ANIM_STEP_PARMS      mciAnimStepParms;
  110.  
  111.     // MCI structure that is needed when changing the window of a movie    
  112.     MCI_ANIM_WINDOW_PARMS    mciAnimWindowParms;
  113.  
  114.     // MCI structure that is needed when seeking within a movie    
  115.     MCI_SEEK_PARMS           mciSeekParms;
  116.  
  117.     FARPROC     lpfnOpenDlgProc;      // Pointer for the Open Dialog Box
  118.     FARPROC     lpfnSeekDlgProc;      // Pointer for the Seek Dialog Box
  119.     FARPROC     lpfnDevCapsDlgProc;   // Pointer for the Device Caps Dialog Box
  120.     FARPROC     lpfnInfoDlgProc;      // Pointer for the Info Dialog Box
  121.     FARPROC     lpfnStatusDlgProc;    // Pointer for the Status Dialog Box
  122.     FARPROC     lpfnAboutDlgProc;     // Pointer for the About Dialog Box
  123.  
  124.     DWORD       dwError;
  125.     RECT        rc;
  126.     HMENU       hSysMenu;             // Handle to the system menu
  127.     char        szAbout[msMAX];
  128.  
  129.     PAINTSTRUCT ps;
  130.     POINT       ptTopLeft;
  131.     POINT       ptBottomRight;
  132.  
  133.  
  134.     switch (message)
  135.     {
  136.     case WM_INITDIALOG:
  137.         hdlgMain = hdlg;
  138.  
  139.         // adds a About option to the system menu
  140.         hSysMenu = GetSystemMenu (hdlg,0);
  141.         AppendMenu (hSysMenu, MF_SEPARATOR, 0, NULL);
  142.  
  143.         LoadString (hMainInstance,IDS_ABOUT, szAbout, sizeof(szAbout)-1);               
  144.         AppendMenu (hSysMenu, MF_STRING, IDM_ABOUT, szAbout);
  145.  
  146.         // sets up the icon for the application   
  147.         SetClassWord (hdlg, GCW_HICON, LoadIcon (hMainInstance, IDI_APPICON));
  148.  
  149.         // Init values to defaults
  150.         //
  151.         bFullScreen = FALSE;
  152.         CheckDlgButton (hdlg, IDCB_MAIN_FULL_SCRN, bFullScreen);
  153.  
  154.         // disable all the controls 
  155.         msSetControlsState (hdlg, FALSE);
  156.  
  157.         return(TRUE);
  158.         break;
  159.  
  160.     case WM_CTLCOLOR:
  161.         if (bFullScreen)
  162.         {
  163.             if (GetDlgItem (hdlg, IDST_MAIN_PLAYWND)
  164.                     == LOWORD (lParam) )
  165.             {
  166.                 msFillWindowColor (GetDlgItem (hdlg, IDST_MAIN_PLAYWND),
  167.                                 GRAY_BRUSH);
  168.             }
  169.         }
  170.         break;
  171.  
  172.     case WM_SYSCOMMAND:
  173.         switch (wParam)
  174.         {
  175.         case IDM_ABOUT:
  176.             lpfnAboutDlgProc = MakeProcInstance (msAboutDlgProc, hMainInstance);
  177.             DialogBox (hMainInstance, IDDLG_ABOUT, hdlg, lpfnAboutDlgProc);
  178.             break;
  179.  
  180.         default:
  181.             break;
  182.         }
  183.         break;
  184.  
  185.     case MM_MCINOTIFY:
  186.         if (wParam == MCI_NOTIFY_SUCCESSFUL)
  187.         {
  188.             // set focus back to the main dialog
  189.             SetFocus (hdlgMain);
  190.  
  191.             msSetControlsState (hdlg, TRUE);  // ungrey all the controls
  192.  
  193.             // set up the window that the movie is to be played in
  194.             if (bFullScreen)
  195.             {
  196.                 mciAnimWindowParms.hWnd = MCI_ANIM_WINDOW_DEFAULT;
  197.                 dwError = mciSendCommand (wDeviceID, MCI_WINDOW,
  198.                                 MCI_ANIM_WINDOW_HWND,
  199.                                 (DWORD) (LPVOID) &mciAnimWindowParms);
  200.  
  201.             }
  202.             else
  203.             {
  204.                 MCI_ANIM_RECT_PARMS mciAnimRectParms;
  205.  
  206.                 mciAnimWindowParms.hWnd = GetDlgItem (hdlg, IDST_MAIN_PLAYWND);
  207.                 dwError = mciSendCommand (wDeviceID, MCI_WINDOW,
  208.                                 MCI_ANIM_WINDOW_HWND,
  209.                                 (DWORD) (LPVOID) &mciAnimWindowParms);
  210.  
  211.                 //  open up some area around the child window ... note that
  212.                 //  setting the animation client area to a smaller size may
  213.                 //  slow the animation due to clipping calculations.
  214.  
  215.                 GetClientRect (mciAnimWindowParms.hWnd, &mciAnimRectParms.rc);
  216.                 mciAnimRectParms.rc.left += 12;
  217.                 mciAnimRectParms.rc.top += 10;
  218.  
  219.                 //  note right & bottom fields are actually extents!!
  220.  
  221.                 mciAnimRectParms.rc.right -= 24;
  222.                 mciAnimRectParms.rc.bottom -= 20;
  223.  
  224.                 dwError = mciSendCommand (wDeviceID, MCI_PUT,
  225.                                 MCI_ANIM_PUT_DESTINATION|MCI_ANIM_RECT,
  226.                                 (DWORD) (LPVOID) &mciAnimRectParms);
  227.             }
  228.  
  229.  
  230.             // show the movie
  231.             dwError = mciSendCommand (wDeviceID, MCI_SEEK,
  232.                         MCI_WAIT | MCI_SEEK_TO_START, (DWORD) (LPVOID) &mciAnimPlayParms);
  233.  
  234.             if (!dwError)
  235.             {
  236.                 dwError = mciSendCommand (wDeviceID, MCI_STOP,
  237.                            MCI_WAIT, (DWORD) (LPVOID) &mciAnimPlayParms);
  238.             }
  239.  
  240.             if (dwError)
  241.             {
  242.                 msDisplayMCIError (dwError);
  243.             }
  244.  
  245.             // set focus back to the main dialog
  246.             SetFocus (hdlgMain);
  247.         }
  248.         else
  249.         {
  250.             dwError = mciSendCommand (wDeviceID, MCI_CLOSE,
  251.                     MCI_WAIT, (DWORD) (LPVOID) &mciAnimPlayParms);
  252.             msSetControlsState (hdlg, FALSE);  // grey all the controls
  253.         }
  254.         break;
  255.  
  256.     case WM_COMMAND:
  257.  
  258.         switch (wParam)
  259.         {
  260.         case IDPB_MAIN_TOSTART:
  261.             dwError = mciSendCommand (wDeviceID, MCI_SEEK,
  262.                         MCI_WAIT | MCI_SEEK_TO_START,
  263.                         (DWORD) (LPVOID) &mciSeekParms);
  264.  
  265.             if (dwError)
  266.             {
  267.                msDisplayMCIError (dwError);
  268.             }
  269.             break;
  270.  
  271.         case IDPB_MAIN_TOEND:
  272.             dwError = mciSendCommand (wDeviceID, MCI_SEEK,
  273.                         MCI_WAIT | MCI_SEEK_TO_END,
  274.                         (DWORD) (LPVOID) &mciSeekParms);
  275.  
  276.             if (dwError)
  277.             {
  278.                msDisplayMCIError (dwError);
  279.             }
  280.             break;
  281.  
  282.         case IDPB_MAIN_DEV_CAP:
  283.             if (wDeviceID != -1)
  284.             {
  285.                 // if the movie is playing then stop it
  286.                 if (msIsMoviePlaying)
  287.                 {
  288.  
  289.                    dwError = mciSendCommand (wDeviceID, MCI_STOP,
  290.                             MCI_WAIT, (DWORD) (LPVOID) &mciAnimPlayParms);
  291.                    if (dwError)
  292.                    {
  293.                         msDisplayMCIError (dwError);
  294.                         break;
  295.                    }
  296.  
  297.                 }
  298.                 lpfnDevCapsDlgProc = MakeProcInstance (msDevCapsDlgProc, hMainInstance);
  299.                 DialogBox (hMainInstance, IDDLG_DEVCAPS, hdlg, lpfnDevCapsDlgProc);
  300.             }
  301.             break;
  302.  
  303.         case IDPB_MAIN_STATUS:
  304.             if (wDeviceID != -1)
  305.             {
  306.                 // if the movie is playing then stop it
  307.                 if (msIsMoviePlaying)
  308.                 {
  309.  
  310.                    dwError = mciSendCommand (wDeviceID, MCI_STOP,
  311.                             MCI_WAIT, (DWORD) (LPVOID) &mciAnimPlayParms);
  312.                    if (dwError)
  313.                    {
  314.                         msDisplayMCIError (dwError);
  315.                         break;
  316.                    }
  317.  
  318.                 }
  319.                 lpfnStatusDlgProc = MakeProcInstance (msStatusDlgProc, hMainInstance);
  320.                 DialogBox (hMainInstance, IDDLG_STATUS, hdlg, lpfnStatusDlgProc);
  321.             }
  322.             break;
  323.  
  324.         case IDPB_MAIN_INFO:
  325.             if (wDeviceID != -1)
  326.             {
  327.                 // if the movie is playing then stop it
  328.                 if (msIsMoviePlaying)
  329.                 {
  330.  
  331.                    dwError = mciSendCommand (wDeviceID, MCI_STOP,
  332.                             MCI_WAIT, (DWORD) (LPVOID) &mciAnimPlayParms);
  333.                    if (dwError)
  334.                    {
  335.                         msDisplayMCIError (dwError);
  336.                         break;
  337.                    }
  338.  
  339.                 }
  340.                 lpfnInfoDlgProc = MakeProcInstance (msInfoDlgProc, hMainInstance);
  341.                 DialogBox (hMainInstance, IDDLG_INFO, hdlg, lpfnInfoDlgProc);
  342.             }
  343.             break;
  344.  
  345.  
  346.         case IDPB_MAIN_SEEK:
  347.             if (wDeviceID != -1)
  348.             {
  349.                 // if the movie is playing then stop it
  350.                 if (msIsMoviePlaying)
  351.                 {
  352.  
  353.                    dwError = mciSendCommand (wDeviceID, MCI_STOP,
  354.                             MCI_WAIT, (DWORD) (LPVOID) &mciAnimPlayParms);
  355.                    if (dwError)
  356.                    {
  357.                         msDisplayMCIError (dwError);
  358.                         break;
  359.                    }
  360.  
  361.                 }
  362.                 lpfnSeekDlgProc = MakeProcInstance (msSeekDlgProc, hMainInstance);
  363.                 DialogBox (hMainInstance, IDDLG_SEEK, hdlg, lpfnSeekDlgProc);
  364.             }
  365.             break;
  366.  
  367.  
  368.         case IDPB_MAIN_STOP:
  369.             dwError = mciSendCommand (wDeviceID, MCI_STOP,
  370.                             MCI_WAIT, (DWORD) (LPVOID) &mciAnimPlayParms);
  371.             if (dwError)
  372.             {
  373.                 msDisplayMCIError (dwError);
  374.             }
  375.             break;
  376.  
  377.         case IDPB_MAIN_PAUSE:
  378.             dwError = mciSendCommand (wDeviceID, MCI_PAUSE,
  379.                         MCI_WAIT, (DWORD) (LPVOID) &mciAnimPlayParms);
  380.  
  381.             if (dwError)
  382.             {
  383.                 msDisplayMCIError (dwError);
  384.             }
  385.             break;
  386.  
  387.         case IDPB_MAIN_CLOSE:
  388.             dwError = mciSendCommand (wDeviceID, MCI_CLOSE,
  389.                     MCI_WAIT, (DWORD) (LPVOID) &mciAnimPlayParms);
  390.  
  391.             if (!dwError)
  392.             {
  393.                 if (wDeviceID != -1)
  394.                     wDeviceID = -1;
  395.  
  396.                 // fill the play window with gray
  397.                 msFillWindowColor (GetDlgItem (hdlg, IDST_MAIN_PLAYWND),
  398.                                 GRAY_BRUSH);
  399.  
  400.                 msSetControlsState (hdlg, FALSE);  // grey all the controls
  401.             }
  402.             else
  403.             {
  404.                 msDisplayMCIError (dwError);
  405.             }
  406.             break;
  407.  
  408.         case IDPB_MAIN_PLAY_FORWARD:
  409.             dwError = mciSendCommand (wDeviceID, MCI_PLAY, 0,
  410.                         (DWORD) (LPVOID) &mciAnimPlayParms);
  411.  
  412.             if (dwError)
  413.             {
  414.                 msDisplayMCIError (dwError);
  415.             }
  416.             break;
  417.  
  418.         case IDPB_MAIN_PLAY_REVERSE:
  419.             dwError = mciSendCommand (wDeviceID, MCI_PLAY,
  420.                         MCI_ANIM_PLAY_REVERSE,
  421.                         (DWORD) (LPVOID) &mciAnimPlayParms);
  422.             if (dwError)
  423.             {
  424.                 msDisplayMCIError (dwError);
  425.             }
  426.             break;
  427.  
  428.         case IDPB_MAIN_STEP_FORWARD:
  429.             mciAnimStepParms.dwFrames = 1;
  430.             dwError = mciSendCommand (wDeviceID, MCI_STEP,
  431.                     MCI_WAIT | MCI_ANIM_STEP_FRAMES,
  432.                     (DWORD) (LPVOID) &mciAnimStepParms);
  433.  
  434.             if (dwError)
  435.             {
  436.                 msDisplayMCIError (dwError);
  437.             }
  438.             break;
  439.  
  440.         case IDPB_MAIN_STEP_REVERSE:
  441.             mciAnimStepParms.dwFrames = 1;
  442.             dwError = mciSendCommand (wDeviceID, MCI_STEP,
  443.                     MCI_WAIT | MCI_ANIM_STEP_FRAMES | MCI_ANIM_STEP_REVERSE,
  444.                     (DWORD) (LPVOID) &mciAnimStepParms);
  445.  
  446.             if (dwError)
  447.             {
  448.                 msDisplayMCIError (dwError);
  449.             }
  450.             break;
  451.  
  452.         case IDPB_MAIN_OPEN:
  453.             // call the open dialog box
  454.             lpfnOpenDlgProc = MakeProcInstance (msOpenDlgProc, hMainInstance);
  455.             DialogBox (hMainInstance, IDDLG_OPEN, hdlg, lpfnOpenDlgProc);
  456.             FreeProcInstance (lpfnOpenDlgProc);
  457.  
  458.             // set focus back to the main dialog
  459.             SetFocus (hdlgMain);
  460.             break;
  461.  
  462.         case IDCB_MAIN_FULL_SCRN:
  463.             if (wDeviceID != -1)
  464.             {
  465.                 if (!bFullScreen)
  466.                 {
  467.                     mciAnimWindowParms.hWnd = MCI_ANIM_WINDOW_DEFAULT;
  468.                     dwError = mciSendCommand (wDeviceID, MCI_WINDOW,
  469.                                     MCI_ANIM_WINDOW_HWND,
  470.                                     (DWORD) (LPVOID) &mciAnimWindowParms);
  471.  
  472.                 }
  473.                 else
  474.                 {
  475.                     mciAnimWindowParms.hWnd = GetDlgItem (hdlg, IDST_MAIN_PLAYWND);
  476.                     dwError = mciSendCommand (wDeviceID, MCI_WINDOW,
  477.                                     MCI_ANIM_WINDOW_HWND,
  478.                                     (DWORD) (LPVOID) &mciAnimWindowParms);
  479.                 }
  480.  
  481.  
  482.                 
  483.                 if (dwError)
  484.                 {
  485.                     msDisplayMCIError (dwError);
  486.                     break;
  487.                 }
  488.                 else
  489.                 {
  490.                     bFullScreen = !bFullScreen;
  491.                     CheckDlgButton (hdlg, IDCB_MAIN_FULL_SCRN, bFullScreen);
  492.                 }
  493.  
  494.                 dwError = mciSendCommand (wDeviceID, MCI_SEEK,
  495.                             MCI_WAIT | MCI_SEEK_TO_START, (DWORD) (LPVOID) &mciAnimPlayParms);
  496.  
  497.                 if (!dwError)
  498.                 {
  499.                     dwError = mciSendCommand (wDeviceID, MCI_STOP,
  500.                                MCI_WAIT, (DWORD) (LPVOID) &mciAnimPlayParms);
  501.                 }
  502.  
  503.  
  504.                 if (dwError)
  505.                 {
  506.                     msDisplayMCIError (dwError);
  507.                 }
  508.                 else
  509.                 {
  510.                     // set focus back to the main dialog
  511.                     SetFocus (hdlg);
  512.                 }
  513.  
  514.                
  515.             }
  516.             break;
  517.  
  518.         default:
  519.             // Message not processed
  520.             return(FALSE);
  521.         }
  522.  
  523.         // Message processed
  524.         return(TRUE);
  525.         break;
  526.  
  527.     case WM_CLOSE:
  528.         if (wDeviceID != -1)
  529.         {
  530.            dwError = mciSendCommand (wDeviceID, MCI_CLOSE,
  531.                         MCI_WAIT, (DWORD) (LPVOID) &mciAnimPlayParms);
  532.  
  533.            if (dwError)
  534.            {
  535.                msDisplayMCIError (dwError);
  536.            }
  537.  
  538.         }
  539.         EndDialog (hdlg, FALSE);
  540.           break;
  541.  
  542.     default:
  543.         // Message not processed
  544.         return(FALSE);
  545.  
  546.     }
  547.     return(FALSE);
  548. }
  549.  
  550.  
  551. /******************************************************************************
  552.  
  553.     Function:    msOpenDlgProc ()        - windows callable
  554.  
  555.     Desc:        Dialog procedure for the 'Open' dialog box.
  556.  
  557.     Returns:    BOOL    TRUE            - OK was pressed
  558.                         FALSE           - Cancel was pressed
  559.  
  560. ******************************************************************************/
  561.  
  562. BOOL FAR PASCAL
  563. msOpenDlgProc (
  564.     HWND        hdlg,
  565.     unsigned    message,
  566.     WORD        wParam,
  567.     LONG        lParam)
  568. {
  569.     // MCI structure that is needed when loading a movie    
  570.     MCI_ANIM_OPEN_PARMS      mciAnimOpenParms;
  571.  
  572.     // MCI structure that is needed when playing a movie    
  573.     MCI_ANIM_PLAY_PARMS      mciAnimPlayParms;
  574.  
  575.     char    szFile[msMAX];
  576.     DWORD   dwError;
  577.  
  578.     switch (message)
  579.     {
  580.     case WM_INITDIALOG:
  581.         SendDlgItemMessage(hdlg, IDEB_OPEN_MOVIE_FILE, EM_LIMITTEXT, msMAX, 0L);
  582.         
  583.         return(TRUE);
  584.         break;
  585.  
  586.     case WM_COMMAND:
  587.  
  588.         switch (wParam)
  589.         {
  590.  
  591.         case IDPB_OK:
  592.             // gets the filename from the dialog
  593.             GetDlgItemText (hdlg, IDEB_OPEN_MOVIE_FILE, szFile,
  594.                 msMAX-1);
  595.  
  596.             // if we already have a movie open then we close it
  597.             if (wDeviceID != -1)
  598.             {
  599.                 mciSendCommand (wDeviceID, MCI_CLOSE,
  600.                     MCI_WAIT, (DWORD) (LPVOID) &mciAnimPlayParms);
  601.  
  602.                 wDeviceID = -1;
  603.             }
  604.  
  605.             // disable all the controls
  606.             msSetControlsState (hdlgMain, FALSE);
  607.  
  608.             mciAnimOpenParms.lpstrDeviceType = NULL;
  609.             mciAnimOpenParms.lpstrElementName = (LPSTR) szFile;
  610.             mciAnimOpenParms.dwStyle = WS_OVERLAPPED | WS_THICKFRAME;
  611.             mciAnimOpenParms.lpstrAlias = "Scarper";
  612.             mciAnimOpenParms.dwCallback = hdlgMain;
  613.  
  614.             dwError = mciSendCommand (NULL, MCI_OPEN,
  615.                     MCI_OPEN_ALIAS | MCI_WAIT | MCI_NOTIFY | MCI_OPEN_ELEMENT | MCI_ANIM_OPEN_WS,
  616.                     (DWORD) (LPVOID) &mciAnimOpenParms);
  617.  
  618.             if (dwError)
  619.             {
  620.                 SetFocus (hdlgMain);
  621.  
  622.                 msDisplayMCIError (dwError);
  623.             }
  624.             else
  625.             {
  626.                 wDeviceID = mciAnimOpenParms.wDeviceID;
  627.             }
  628.  
  629.             // if there was an error we return FALSE, else return TRUE
  630.             EndDialog (hdlg, !dwError);
  631.             break;
  632.  
  633.         case IDPB_CANCEL:
  634.             EndDialog (hdlg, FALSE);
  635.             break;
  636.  
  637.         default:
  638.             // Message not processed
  639.             return(FALSE);
  640.         }
  641.  
  642.         // Message processed
  643.         return(TRUE);
  644.         break;
  645.  
  646.     case WM_CLOSE:
  647.         EndDialog (hdlg, FALSE);
  648.           break;
  649.  
  650.     default:
  651.         // Message not processed
  652.         return(FALSE);
  653.  
  654.     }
  655.     return(FALSE);
  656. }
  657.  
  658.  
  659. /******************************************************************************
  660.  
  661.     Function:    msSeekDlgProc ()        - windows callable
  662.  
  663.     Desc:        Dialog procedure for the 'Seek' dialog box.
  664.  
  665.     Returns:    BOOL    TRUE            - OK was pressed
  666.                         FALSE           - Cancel was pressed
  667.  
  668. ******************************************************************************/
  669.  
  670. BOOL FAR PASCAL
  671. msSeekDlgProc (
  672.     HWND        hdlg,
  673.     unsigned    message,
  674.     WORD        wParam,
  675.     LONG        lParam)
  676. {
  677.  
  678.     // MCI structure that is needed when seeking within movie    
  679.     MCI_SEEK_PARMS           mciSeekParms;
  680.  
  681.     int     nToFrame;
  682.     BOOL    bNoError;
  683.     DWORD   dwError;
  684.  
  685.     switch (message)
  686.     {
  687.  
  688.     case WM_INITDIALOG:
  689.         
  690.         return(TRUE);
  691.         break;
  692.  
  693.     case WM_COMMAND:
  694.  
  695.         switch (wParam)
  696.         {
  697.  
  698.         case IDPB_OK:
  699.             nToFrame = GetDlgItemInt (hdlg, IDEB_SEEK_TOFRAME, &bNoError, FALSE);
  700.  
  701.             if (bNoError)
  702.             {
  703.                 mciSeekParms.dwTo = nToFrame;
  704.                 dwError = mciSendCommand (wDeviceID, MCI_SEEK,
  705.                         MCI_WAIT | MCI_TO,
  706.                         (DWORD) (LPVOID) &mciSeekParms);
  707.  
  708.                 if (dwError)
  709.                 {
  710.                    msDisplayMCIError (dwError);
  711.                 }
  712.                 else
  713.                 {
  714.                     EndDialog (hdlg, FALSE);
  715.                 }
  716.             }
  717.             break;
  718.  
  719.         case IDPB_CANCEL:
  720.             EndDialog (hdlg, FALSE);
  721.             break;
  722.  
  723.         default:
  724.             // Message not processed
  725.             return(FALSE);
  726.         }
  727.  
  728.         // Message processed
  729.         return(TRUE);
  730.         break;
  731.  
  732.     case WM_CLOSE:
  733.         EndDialog (hdlg, FALSE);
  734.           break;
  735.  
  736.     default:
  737.         // Message not processed
  738.         return(FALSE);
  739.  
  740.     }
  741.     return(FALSE);
  742. }
  743.  
  744.  
  745. /******************************************************************************
  746.  
  747.     Function:    msDisplayError ()        - local
  748.  
  749.     Desc:        Handles all the error message for the MCI commands.
  750.  
  751.     Returns:    VOID
  752.                     
  753.  
  754. ******************************************************************************/
  755.  
  756. VOID
  757. msDisplayMCIError (DWORD dwError)
  758. {
  759.     char        szError[msMAX];
  760.     char        szTitle[msMAX];
  761.  
  762.     // converts the ID of the error into a string and displays it to the user
  763.     mciGetErrorString (dwError, szError, msMAX-1);
  764.     LoadString (hMainInstance,IDS_ERROR_TITLE, szTitle, sizeof(szTitle)-1);               
  765.     MessageBox (NULL, szError, szTitle,MB_ICONSTOP | MB_OK | MB_TASKMODAL);
  766. }
  767.  
  768. static VOID msEnableDlgItem (HWND hdlg, WORD wId, BOOL bEnable)
  769. {
  770.     HWND    hwnd = GetDlgItem (hdlg, wId);
  771.  
  772.     if (IsWindow (hwnd))
  773.         EnableWindow (hwnd, bEnable);
  774. }
  775.  
  776. /******************************************************************************
  777.  
  778.     Function:    msSetControlsState ()        - local
  779.  
  780.     Desc:        Enable or disables all the controls (expect Open).
  781.  
  782.     Returns:    VOID
  783.                     
  784.  
  785. ******************************************************************************/
  786.  
  787. VOID
  788. msSetControlsState (
  789. HWND hdlg,
  790. BOOL bState)
  791. {
  792.     // Need to Grey all the control that can't be used
  793.     // unless a movie has been opened
  794.     msEnableDlgItem (hdlg, IDPB_MAIN_CLOSE, bState);
  795.     msEnableDlgItem (hdlg, IDCB_MAIN_FULL_SCRN, bState);
  796.     msEnableDlgItem (hdlg, IDPB_MAIN_STOP, bState);
  797.     msEnableDlgItem (hdlg, IDPB_MAIN_PAUSE, bState);
  798.     msEnableDlgItem (hdlg, IDPB_MAIN_PLAY_FORWARD, bState);
  799.     msEnableDlgItem (hdlg, IDPB_MAIN_PLAY_REVERSE, bState);
  800.     msEnableDlgItem (hdlg, IDPB_MAIN_STEP_REVERSE, bState);
  801.     msEnableDlgItem (hdlg, IDPB_MAIN_STEP_FORWARD, bState);
  802.     msEnableDlgItem (hdlg, IDPB_MAIN_SEEK, bState);
  803.     msEnableDlgItem (hdlg, IDPB_MAIN_DEV_CAP, bState);
  804.     msEnableDlgItem (hdlg, IDPB_MAIN_STATUS, bState);
  805.     msEnableDlgItem (hdlg, IDPB_MAIN_INFO, bState);
  806.     msEnableDlgItem (hdlg, IDPB_MAIN_TOSTART, bState);
  807.     msEnableDlgItem (hdlg, IDPB_MAIN_TOEND, bState);
  808. }
  809.  
  810.  
  811. /******************************************************************************
  812.  
  813.     Function:    msDevCapsDlgProc ()        - windows callable
  814.  
  815.     Desc:        Dialog procedure for the 'Device Capabilities' dialog box.
  816.  
  817.     Returns:    BOOL    TRUE            - OK was pressed
  818.                         FALSE           - Cancel was pressed
  819.  
  820. ******************************************************************************/
  821.  
  822. BOOL FAR PASCAL
  823. msDevCapsDlgProc (
  824.     HWND        hdlg,
  825.     unsigned    message,
  826.     WORD        wParam,
  827.     LONG        lParam)
  828. {
  829.  
  830.     MCI_GETDEVCAPS_PARMS     mciGetDevCapsParms;
  831.     DWORD       dwResult;
  832.     char        szResult[msMAX];
  833.  
  834.     switch (message)
  835.     {
  836.  
  837.     case WM_INITDIALOG:
  838.  
  839.         // set dialog if the device can be ejected
  840.         msSetDlgItemCaps (hdlg,
  841.                           MCI_GETDEVCAPS_CAN_EJECT,
  842.                           IDST_DEVCAP_EJECT);
  843.  
  844.         // sets dialog if the device can be played
  845.         msSetDlgItemCaps (hdlg,
  846.                           MCI_GETDEVCAPS_CAN_PLAY,
  847.                           IDST_DEVCAP_PLAY);
  848.  
  849.         // sets dialog if the device can be record
  850.         msSetDlgItemCaps (hdlg,
  851.                           MCI_GETDEVCAPS_CAN_RECORD,
  852.                           IDST_DEVCAP_RECORD);
  853.  
  854.         // sets dialog if the device can be save
  855.         msSetDlgItemCaps (hdlg,
  856.                           MCI_GETDEVCAPS_CAN_SAVE,
  857.                           IDST_DEVCAP_SAVE);
  858.  
  859.         // sets dialog if the device can use device elements
  860.         msSetDlgItemCaps (hdlg,
  861.                           MCI_GETDEVCAPS_COMPOUND_DEVICE,
  862.                           IDST_DEVCAP_DEVELE);
  863.  
  864.         // finds out the type of device we are working with
  865.         mciGetDevCapsParms.dwItem = MCI_GETDEVCAPS_DEVICE_TYPE;
  866.         mciSendCommand (wDeviceID, MCI_GETDEVCAPS,
  867.                     MCI_WAIT | MCI_GETDEVCAPS_ITEM,
  868.                     (DWORD) (LPVOID) &mciGetDevCapsParms);
  869.  
  870.         dwResult = mciGetDevCapsParms.dwReturn;
  871.         switch (dwResult)
  872.         {
  873.         case MCI_DEVTYPE_ANIMATION:
  874.             LoadString (hMainInstance,IDS_DEVTYPE_ANIMATION,
  875.                             szResult, sizeof(szResult)-1);               
  876.             SetWindowText (GetDlgItem (hdlg, IDST_DEVCAP_DEVTYPE), szResult);
  877.             break;
  878.  
  879.         case MCI_DEVTYPE_CD_AUDIO:
  880.             LoadString (hMainInstance,IDS_DEVTYPE_CD_AUDIO,
  881.                             szResult, sizeof(szResult)-1);               
  882.             SetWindowText (GetDlgItem (hdlg, IDST_DEVCAP_DEVTYPE), szResult);
  883.             break;
  884.  
  885.         case MCI_DEVTYPE_DAT:
  886.             LoadString (hMainInstance,IDS_DEVTYPE_DAT,
  887.                             szResult, sizeof(szResult)-1);               
  888.             SetWindowText (GetDlgItem (hdlg, IDST_DEVCAP_DEVTYPE), szResult);
  889.             break;
  890.  
  891.         case MCI_DEVTYPE_DIGITAL_VIDEO:
  892.             LoadString (hMainInstance,IDS_DEVTYPE_DIGITAL_VIDEO,
  893.                             szResult, sizeof(szResult)-1);               
  894.             SetWindowText (GetDlgItem (hdlg, IDST_DEVCAP_DEVTYPE), szResult);
  895.             break;
  896.  
  897.         case MCI_DEVTYPE_OTHER:
  898.             LoadString (hMainInstance,IDS_DEVTYPE_OTHER,
  899.                             szResult, sizeof(szResult)-1);               
  900.             SetWindowText (GetDlgItem (hdlg, IDST_DEVCAP_DEVTYPE), szResult);
  901.             break;
  902.  
  903.         case MCI_DEVTYPE_OVERLAY:
  904.             LoadString (hMainInstance,IDS_DEVTYPE_OVERLAY,
  905.                             szResult, sizeof(szResult)-1);               
  906.             SetWindowText (GetDlgItem (hdlg, IDST_DEVCAP_DEVTYPE), szResult);
  907.             break;
  908.  
  909.         case MCI_DEVTYPE_SCANNER:
  910.             LoadString (hMainInstance,IDS_DEVTYPE_SCANNER,
  911.                             szResult, sizeof(szResult)-1);               
  912.             SetWindowText (GetDlgItem (hdlg, IDST_DEVCAP_DEVTYPE), szResult);
  913.             break;
  914.  
  915.         case MCI_DEVTYPE_SEQUENCER:
  916.             LoadString (hMainInstance,IDS_DEVTYPE_SEQUENCER,
  917.                             szResult, sizeof(szResult)-1);               
  918.             SetWindowText (GetDlgItem (hdlg, IDST_DEVCAP_DEVTYPE), szResult);
  919.             break;
  920.  
  921.         case MCI_DEVTYPE_VIDEODISC:
  922.             LoadString (hMainInstance,IDS_DEVTYPE_VIDEODISC,
  923.                             szResult, sizeof(szResult)-1);               
  924.             SetWindowText (GetDlgItem (hdlg, IDST_DEVCAP_DEVTYPE), szResult);
  925.             break;
  926.  
  927. // Video not supported in the version of MCI I am working with
  928. //      case MCI_DEVTYPE_VIDEOTAPE:
  929. //          LoadString (hMainInstance,IDS_DEVTYPE_VIDEOTAPE,
  930. //                          szResult, sizeof(szResult)-1);               
  931. //          SetWindowText (GetDlgItem (hdlg, IDST_DEVCAP_DEVTYPE), szResult);
  932. //          break;
  933.  
  934.  
  935.         case MCI_DEVTYPE_WAVEFORM_AUDIO:
  936.             LoadString (hMainInstance,IDS_DEVTYPE_WAVEFORM_AUDIO,
  937.                             szResult, sizeof(szResult)-1);               
  938.             SetWindowText (GetDlgItem (hdlg, IDST_DEVCAP_DEVTYPE), szResult);
  939.             break;
  940.  
  941.  
  942.         deafault:
  943.             LoadString (hMainInstance,IDS_UNKNOWN,
  944.                             szResult, sizeof(szResult)-1);               
  945.             SetWindowText (GetDlgItem (hdlg, IDST_DEVCAP_DEVTYPE), szResult);
  946.             break;
  947.  
  948.         }
  949.  
  950.  
  951.         // sets dialog if the device has audio
  952.         msSetDlgItemCaps (hdlg,
  953.                           MCI_GETDEVCAPS_HAS_AUDIO,
  954.                           IDST_DEVCAP_AUDIO);
  955.  
  956.   
  957.         // sets dialog if the device has video
  958.         msSetDlgItemCaps (hdlg,
  959.                           MCI_GETDEVCAPS_HAS_VIDEO,
  960.                           IDST_DEVCAP_VIDEO);
  961.  
  962.    
  963.         // sets dialog if the device can use user files 
  964.         msSetDlgItemCaps (hdlg,
  965.                           MCI_GETDEVCAPS_USES_FILES,
  966.                           IDST_DEVCAP_USESFILES);
  967.  
  968.  
  969.         // sets dialog if the device can play in reverse
  970.         msSetDlgItemCaps (hdlg,
  971.                           MCI_ANIM_GETDEVCAPS_CAN_REVERSE,
  972.                           IDST_DEVCAP_PLAYREVERSE);
  973.  
  974.  
  975.         // sets dialog if the device can stretch
  976.         msSetDlgItemCaps (hdlg,
  977.                           MCI_ANIM_GETDEVCAPS_CAN_STRETCH,
  978.                           IDST_DEVCAP_STRETCH);
  979.  
  980.  
  981.         // finds out the fast rate of the device 
  982.         mciGetDevCapsParms.dwItem = MCI_ANIM_GETDEVCAPS_FAST_RATE;
  983.         mciSendCommand (wDeviceID, MCI_GETDEVCAPS,
  984.                     MCI_WAIT | MCI_GETDEVCAPS_ITEM,
  985.                     (DWORD) (LPVOID) &mciGetDevCapsParms);
  986.  
  987.         dwResult = mciGetDevCapsParms.dwReturn;
  988.         if (dwResult == MCIERR_UNSUPPORTED_FUNCTION)
  989.         {
  990.             LoadString (hMainInstance,IDS_UNSUPPORTED_FUNCTION,
  991.                             szResult, sizeof(szResult)-1);
  992.             SetWindowText (GetDlgItem (hdlg, IDST_DEVCAP_FASTRATE), szResult);
  993.         }
  994.         else
  995.         {
  996.             ltoa (dwResult, szResult, 10);
  997.             SetWindowText (GetDlgItem (hdlg, IDST_DEVCAP_FASTRATE), szResult);
  998.         }
  999.  
  1000.  
  1001.         // finds out the normal rate of the device 
  1002.         mciGetDevCapsParms.dwItem = MCI_ANIM_GETDEVCAPS_NORMAL_RATE;
  1003.         mciSendCommand (wDeviceID, MCI_GETDEVCAPS,
  1004.                     MCI_WAIT | MCI_GETDEVCAPS_ITEM,
  1005.                     (DWORD) (LPVOID) &mciGetDevCapsParms);
  1006.  
  1007.         dwResult = mciGetDevCapsParms.dwReturn;
  1008.         if (dwResult == MCIERR_UNSUPPORTED_FUNCTION)
  1009.         {
  1010.             LoadString (hMainInstance,IDS_UNSUPPORTED_FUNCTION,
  1011.                             szResult, sizeof(szResult)-1);
  1012.             SetWindowText (GetDlgItem (hdlg, IDST_DEVCAP_NORMRATE), szResult);
  1013.         }
  1014.         else
  1015.         {
  1016.             ltoa (dwResult, szResult, 10);
  1017.             SetWindowText (GetDlgItem (hdlg, IDST_DEVCAP_NORMRATE), szResult);
  1018.         }
  1019.  
  1020.  
  1021.         // finds out the slow rate of the device 
  1022.         mciGetDevCapsParms.dwItem = MCI_ANIM_GETDEVCAPS_SLOW_RATE;
  1023.         mciSendCommand (wDeviceID, MCI_GETDEVCAPS,
  1024.                     MCI_WAIT | MCI_GETDEVCAPS_ITEM,
  1025.                     (DWORD) (LPVOID) &mciGetDevCapsParms);
  1026.  
  1027.         dwResult = mciGetDevCapsParms.dwReturn;
  1028.         if (dwResult == MCIERR_UNSUPPORTED_FUNCTION)
  1029.         {
  1030.             LoadString (hMainInstance,IDS_UNSUPPORTED_FUNCTION,
  1031.                             szResult, sizeof(szResult)-1);
  1032.             SetWindowText (GetDlgItem (hdlg, IDST_DEVCAP_SLOWRATE), szResult);
  1033.         }
  1034.         else
  1035.         {
  1036.             ltoa (dwResult, szResult, 10);
  1037.             SetWindowText (GetDlgItem (hdlg, IDST_DEVCAP_SLOWRATE), szResult);
  1038.         }
  1039.  
  1040.   
  1041.         // finds out the max windows this device can handle 
  1042.         mciGetDevCapsParms.dwItem = MCI_ANIM_GETDEVCAPS_MAX_WINDOWS;
  1043.         mciSendCommand (wDeviceID, MCI_GETDEVCAPS,
  1044.                     MCI_WAIT | MCI_GETDEVCAPS_ITEM,
  1045.                     (DWORD) (LPVOID) &mciGetDevCapsParms);
  1046.  
  1047.         dwResult = mciGetDevCapsParms.dwReturn;
  1048.         ltoa (dwResult, szResult, 10);
  1049.         SetWindowText (GetDlgItem (hdlg, IDST_DEVCAP_MAXWIN), szResult);
  1050.  
  1051.  
  1052.  
  1053.         // sets dialog if the device can use palettes
  1054.         msSetDlgItemCaps (hdlg,
  1055.                           MCI_ANIM_GETDEVCAPS_PALETTES,
  1056.                           IDST_DEVCAP_PALETTE);
  1057.  
  1058.         return(TRUE);
  1059.         break;
  1060.  
  1061.     case WM_COMMAND:
  1062.  
  1063.         switch (wParam)
  1064.         {
  1065.  
  1066.         case IDPB_OK:
  1067.             EndDialog (hdlg, TRUE);
  1068.             break;
  1069.  
  1070.  
  1071.         default:
  1072.             // Message not processed
  1073.             return(FALSE);
  1074.         }
  1075.  
  1076.         // Message processed
  1077.         return(TRUE);
  1078.         break;
  1079.  
  1080.     case WM_CLOSE:
  1081.         EndDialog (hdlg, FALSE);
  1082.           break;
  1083.  
  1084.     default:
  1085.         // Message not processed
  1086.         return(FALSE);
  1087.  
  1088.     }
  1089.     return(FALSE);
  1090. }
  1091.  
  1092.  
  1093. /******************************************************************************
  1094.  
  1095.     Function:    msInfoDlgProc ()        - windows callable
  1096.  
  1097.     Desc:        Dialog procedure for the 'Info' dialog box.
  1098.  
  1099.     Returns:    BOOL    TRUE            - OK was pressed
  1100.                         FALSE           - Cancel was pressed
  1101.  
  1102. ******************************************************************************/
  1103.  
  1104. BOOL FAR PASCAL
  1105. msInfoDlgProc (
  1106.     HWND        hdlg,
  1107.     unsigned    message,
  1108.     WORD        wParam,
  1109.     LONG        lParam)
  1110. {
  1111.     MCI_VERSION_PARMS      mciVerParms;
  1112.     MCI_GETDEVCAPS_PARMS   mciGetDevCapsParms;
  1113.     MCI_INFO_PARMS         mciInfoParms;
  1114.  
  1115.     char        szResult[msMAX];
  1116.     DWORD       dwError;
  1117.     char        szIn[msMAX];
  1118.     char        szOut[msMAX];
  1119.  
  1120.  
  1121.     switch (message)
  1122.     {
  1123.  
  1124.     case WM_INITDIALOG:
  1125.  
  1126.         // finds out if the device can use user files 
  1127.         mciGetDevCapsParms.dwItem = MCI_GETDEVCAPS_USES_FILES;
  1128.         mciSendCommand (wDeviceID, MCI_GETDEVCAPS,
  1129.                     MCI_WAIT | MCI_GETDEVCAPS_ITEM,
  1130.                     (DWORD) (LPVOID) &mciGetDevCapsParms);
  1131.  
  1132.  
  1133.         if (mciGetDevCapsParms.dwReturn)
  1134.         {
  1135.             // finds out the filename of the device 
  1136.             mciInfoParms.lpstrReturn = szResult;
  1137.             mciInfoParms.dwRetSize = sizeof(szResult);
  1138.  
  1139.             dwError = mciSendCommand (wDeviceID, MCI_INFO,
  1140.                         MCI_WAIT | MCI_INFO_FILE,
  1141.                         (DWORD) (LPVOID) &mciInfoParms);
  1142.  
  1143.             if (dwError)
  1144.             {
  1145.                msDisplayMCIError (dwError);
  1146.             }
  1147.             else
  1148.             {
  1149.  
  1150.                  SetWindowText (GetDlgItem (hdlg, IDST_INFO_FILENAME),
  1151.                             mciInfoParms.lpstrReturn);
  1152.             }
  1153.  
  1154.         }
  1155.         else
  1156.         {
  1157.             LoadString (hMainInstance,IDS_UNSUPPORTED_FUNCTION,
  1158.                             szResult, sizeof(szResult)-1);
  1159.             SetWindowText (GetDlgItem (hdlg, IDST_INFO_FILENAME), szResult);
  1160.         }
  1161.  
  1162.         
  1163.  
  1164.  
  1165.         // finds out the caption on the window of the device
  1166.         dwError = mciSendCommand (wDeviceID, MCI_INFO,
  1167.                     MCI_ANIM_INFO_TEXT,
  1168.                     (DWORD) (LPVOID) &mciInfoParms);
  1169.  
  1170.         if (dwError)
  1171.         {
  1172.             msDisplayMCIError (dwError);
  1173.         }
  1174.         else
  1175.         {
  1176.             SetWindowText (GetDlgItem (hdlg, IDST_INFO_CAPTION),
  1177.                        mciInfoParms.lpstrReturn);
  1178.         }
  1179.  
  1180.         // finds out the product info
  1181.         dwError = mciSendCommand (wDeviceID, MCI_INFO,
  1182.                     MCI_INFO_PRODUCT,
  1183.                     (DWORD) (LPVOID) &mciInfoParms);
  1184.  
  1185.         if (dwError)
  1186.         {
  1187.             msDisplayMCIError (dwError);
  1188.         }
  1189.         else
  1190.         {
  1191.             SetWindowText (GetDlgItem (hdlg, IDST_INFO_PRODUCT),
  1192.                        mciInfoParms.lpstrReturn);
  1193.  
  1194.         }
  1195.  
  1196.         // Get the MCI driver version number
  1197.         //
  1198.  
  1199.         dwError = mciSendCommand (wDeviceID,
  1200.             GOLDDISK_MCI_GETVER, 0, (DWORD) (LPVOID)&mciVerParms);
  1201.  
  1202.         // To use mciSendString we need to use an alias like "Scarper"
  1203.         // the version is returned in the dwReturn field of the mciVerParms struct
  1204.         // eg. dwError = mciSendString ("version Scarper", szOut, sizeof (szOut), &mciVerParms);
  1205.  
  1206.         if (dwError)
  1207.         {
  1208.             msDisplayMCIError (dwError);
  1209.         }
  1210.         else
  1211.         {
  1212.             GetDlgItemText (hdlg, IDST_INFO_DDVERSION, (LPSTR) szIn, sizeof(szIn)-1);
  1213.             wsprintf ((LPSTR) szOut, "%s %d.%02.02d.%02.02d", (LPSTR) szIn,
  1214.             GetRValue(mciVerParms.dwReturn), GetGValue(mciVerParms.dwReturn),
  1215.             GetBValue(mciVerParms.dwReturn));
  1216.  
  1217.             SetDlgItemText (hdlg, IDST_INFO_DDVERSION, (LPSTR) szOut);
  1218.         }
  1219.         return(TRUE);
  1220.         break;
  1221.  
  1222.  
  1223.     case WM_COMMAND:
  1224.  
  1225.         switch (wParam)
  1226.         {
  1227.         case IDPB_OK:
  1228.             EndDialog (hdlg, TRUE);
  1229.             break;
  1230.  
  1231.         default:
  1232.             // Message not processed
  1233.             return(FALSE);
  1234.         }
  1235.  
  1236.         // Message processed
  1237.         return(TRUE);
  1238.         break;
  1239.  
  1240.     case WM_CLOSE:
  1241.         EndDialog (hdlg, FALSE);
  1242.           break;
  1243.  
  1244.     default:
  1245.         // Message not processed
  1246.         return(FALSE);
  1247.  
  1248.     }
  1249.     return(FALSE);
  1250. }
  1251.  
  1252.  
  1253. /******************************************************************************
  1254.  
  1255.     Function:    msStatusDlgProc ()        - windows callable
  1256.  
  1257.     Desc:        Dialog procedure for the 'Status' dialog box.
  1258.  
  1259.     Returns:    BOOL    TRUE            - OK was pressed
  1260.                         FALSE           - Cancel was pressed
  1261.  
  1262. ******************************************************************************/
  1263.  
  1264. BOOL FAR PASCAL
  1265. msStatusDlgProc (
  1266.     HWND        hdlg,
  1267.     unsigned    message,
  1268.     WORD        wParam,
  1269.     LONG        lParam)
  1270. {
  1271.     MCI_SET_PARMS            mciSetParms;
  1272.     MCI_STATUS_PARMS         mciStatusParms;
  1273.     char        szResult[msMAX];
  1274.     DWORD       dwError;
  1275.  
  1276.  
  1277.     switch (message)
  1278.     {
  1279.  
  1280.     case WM_INITDIALOG:
  1281.  
  1282.         // sets the time format to frames
  1283.         mciSetParms.dwTimeFormat = MCI_FORMAT_FRAMES;
  1284.         mciSendCommand (wDeviceID, MCI_SET, (DWORD) MCI_SET_TIME_FORMAT,
  1285.             (DWORD) (LPSTR) &mciSetParms);
  1286.  
  1287.         // we only have one movie
  1288.         mciStatusParms.dwTrack = (DWORD) 1;
  1289.  
  1290.  
  1291.         // finds out the current frame the movie is on
  1292.         mciStatusParms.dwItem = MCI_STATUS_POSITION;
  1293.  
  1294.         dwError = mciSendCommand (wDeviceID, MCI_STATUS,
  1295.                     (DWORD) MCI_STATUS_ITEM,
  1296.                     (DWORD) (LPSTR)(&mciStatusParms));
  1297.  
  1298.         if (dwError)
  1299.         {
  1300.             msDisplayMCIError (dwError);
  1301.         }
  1302.         else
  1303.         {
  1304.             ltoa (mciStatusParms.dwReturn, szResult, 10);
  1305.             SetWindowText (GetDlgItem (hdlg, IDST_STATUS_CURRFRAME), szResult);
  1306.         }
  1307.  
  1308.  
  1309.         // finds out the number of frames in the movie
  1310.         mciStatusParms.dwItem = MCI_STATUS_LENGTH;
  1311.  
  1312.         dwError = mciSendCommand (wDeviceID, MCI_STATUS,
  1313.                     (DWORD) MCI_STATUS_ITEM | MCI_TRACK,
  1314.                     (DWORD) (LPSTR)(&mciStatusParms));
  1315.  
  1316.         if (dwError)
  1317.         {
  1318.             msDisplayMCIError (dwError);
  1319.         }
  1320.         else
  1321.         {
  1322.             ltoa (mciStatusParms.dwReturn, szResult, 10);
  1323.             SetWindowText (GetDlgItem (hdlg, IDST_STATUS_NUMFRAMES), szResult);
  1324.         }
  1325.  
  1326.         // finds out the mode of the movie
  1327.         mciStatusParms.dwItem = MCI_STATUS_MODE;
  1328.  
  1329.         dwError = mciSendCommand (wDeviceID, MCI_STATUS,
  1330.                     (DWORD) MCI_STATUS_ITEM,
  1331.                     (DWORD) (LPSTR)(&mciStatusParms));
  1332.  
  1333.         if (dwError)
  1334.         {
  1335.             msDisplayMCIError (dwError);
  1336.         }
  1337.         else
  1338.         {
  1339.             switch (mciStatusParms.dwReturn)
  1340.             {
  1341.             case MCI_MODE_NOT_READY:
  1342.                 LoadString (hMainInstance, IDS_MODE_NOT_READY,
  1343.                             szResult, sizeof(szResult)-1);               
  1344.                 SetWindowText (GetDlgItem (hdlg, IDST_STATUS_CURRMODE), szResult);
  1345.                 break;
  1346.  
  1347.             case MCI_MODE_PAUSE:
  1348.                 LoadString (hMainInstance,IDS_MODE_PAUSE,
  1349.                             szResult, sizeof(szResult)-1);               
  1350.                 SetWindowText (GetDlgItem (hdlg, IDST_STATUS_CURRMODE), szResult);
  1351.                 break;
  1352.  
  1353.             case MCI_MODE_PLAY:
  1354.                 // finds out if we are playing forward
  1355.                 mciStatusParms.dwItem = MCI_ANIM_STATUS_FORWARD;
  1356.  
  1357.                 dwError = mciSendCommand (wDeviceID, MCI_STATUS,
  1358.                             (DWORD) MCI_STATUS_ITEM,
  1359.                             (DWORD) (LPSTR)(&mciStatusParms));
  1360.  
  1361.                 if (dwError)
  1362.                 {
  1363.                     msDisplayMCIError (dwError);
  1364.                 }
  1365.  
  1366.                 if (mciStatusParms.dwReturn)
  1367.                 {
  1368.                     LoadString (hMainInstance,IDS_MODE_PLAY_FORWARD,
  1369.                             szResult, sizeof(szResult)-1);               
  1370.                     SetWindowText (GetDlgItem (hdlg, IDST_STATUS_CURRMODE), szResult);
  1371.  
  1372.                 }
  1373.                 else
  1374.                 {
  1375.                     LoadString (hMainInstance,IDS_MODE_PLAY_REVERSE,
  1376.                             szResult, sizeof(szResult)-1);               
  1377.                     SetWindowText (GetDlgItem (hdlg, IDST_STATUS_CURRMODE), szResult);
  1378.  
  1379.                 }
  1380.                 break;
  1381.  
  1382.             case MCI_MODE_STOP:
  1383.                  LoadString (hMainInstance,IDS_MODE_STOP,
  1384.                          szResult, sizeof(szResult)-1);               
  1385.                  SetWindowText (GetDlgItem (hdlg, IDST_STATUS_CURRMODE), szResult);
  1386.                  break;
  1387.  
  1388.             case MCI_MODE_OPEN:
  1389.                  LoadString (hMainInstance,IDS_MODE_OPEN,
  1390.                          szResult, sizeof(szResult)-1);               
  1391.                  SetWindowText (GetDlgItem (hdlg, IDST_STATUS_CURRMODE), szResult);
  1392.                  break;
  1393.  
  1394.             case MCI_MODE_RECORD:
  1395.                  LoadString (hMainInstance,IDS_MODE_RECORD,
  1396.                          szResult, sizeof(szResult)-1);               
  1397.                  SetWindowText (GetDlgItem (hdlg, IDST_STATUS_CURRMODE), szResult);
  1398.                  break;
  1399.  
  1400.             case MCI_MODE_SEEK:
  1401.                  LoadString (hMainInstance,IDS_MODE_SEEK,
  1402.                          szResult, sizeof(szResult)-1);               
  1403.                  SetWindowText (GetDlgItem (hdlg, IDST_STATUS_CURRMODE), szResult);
  1404.                  break;
  1405.  
  1406.  
  1407.             default:
  1408.                 LoadString (hMainInstance,IDS_UNKNOWN,
  1409.                             szResult, sizeof(szResult)-1);               
  1410.                 SetWindowText (GetDlgItem (hdlg, IDST_STATUS_CURRMODE), szResult);
  1411.             break;
  1412.  
  1413.  
  1414.  
  1415.             }
  1416.         }
  1417.  
  1418.  
  1419.         // finds out the speed of animation 
  1420.         mciStatusParms.dwItem = MCI_ANIM_STATUS_SPEED;
  1421.         dwError = mciSendCommand (wDeviceID, MCI_STATUS,
  1422.                     (DWORD) MCI_STATUS_ITEM,
  1423.                     (DWORD) (LPSTR)(&mciStatusParms));
  1424.  
  1425.         if (dwError)
  1426.         {
  1427.             msDisplayMCIError (dwError);
  1428.         }
  1429.         else
  1430.         {
  1431.             ltoa (mciStatusParms.dwReturn, szResult, 10);
  1432.             SetWindowText (GetDlgItem (hdlg, IDST_STATUS_SPEED), szResult);
  1433.         }
  1434.  
  1435.         mciStatusParms.dwItem = MCI_ANIM_STATUS_HWND;
  1436.  
  1437.         dwError = mciSendCommand (wDeviceID, MCI_STATUS,
  1438.                     (DWORD) MCI_STATUS_ITEM,
  1439.                     (DWORD) (LPSTR)(&mciStatusParms));
  1440.  
  1441.         if (dwError)
  1442.         {
  1443.             msDisplayMCIError (dwError);
  1444.         }
  1445.         else
  1446.         {
  1447.             SetDlgItemInt (hdlg, IDST_STATUS_HWND, (WORD)mciStatusParms.dwReturn, FALSE);
  1448.         }
  1449.  
  1450.         return(TRUE);
  1451.         break;
  1452.  
  1453.  
  1454.     case WM_COMMAND:
  1455.  
  1456.         switch (wParam)
  1457.         {
  1458.  
  1459.         case IDPB_OK:
  1460.             EndDialog (hdlg, TRUE);
  1461.             break;
  1462.  
  1463.         default:
  1464.             // Message not processed
  1465.             return(FALSE);
  1466.         }
  1467.  
  1468.         // Message processed
  1469.         return(TRUE);
  1470.         break;
  1471.  
  1472.     case WM_CLOSE:
  1473.         EndDialog (hdlg, FALSE);
  1474.           break;
  1475.  
  1476.     default:
  1477.         // Message not processed
  1478.         return(FALSE);
  1479.  
  1480.     }
  1481.     return(FALSE);
  1482. }
  1483.  
  1484.  
  1485. /******************************************************************************
  1486.  
  1487.     Function:    msAboutDlgProc ()        - windows callable
  1488.  
  1489.     Desc:        Dialog procedure for the 'About' dialog box.
  1490.  
  1491.     Returns:    BOOL    TRUE            - OK was pressed
  1492.  
  1493. ******************************************************************************/
  1494.  
  1495. BOOL FAR PASCAL
  1496. msAboutDlgProc (
  1497.     HWND        hdlg,
  1498.     unsigned    message,
  1499.     WORD        wParam,
  1500.     LONG        lParam)
  1501. {
  1502.     char        szResult[msMAX];
  1503.     char        szIn[msMAX];
  1504.     char        szOut[msMAX];
  1505.     DWORD       dwError;
  1506.  
  1507.     switch (message)
  1508.     {
  1509.  
  1510.     case WM_INITDIALOG:
  1511.         // Set the version number
  1512.         //
  1513.         GetDlgItemText (hdlg, IDST_VERSION, (LPSTR) szIn, sizeof(szIn)-1);
  1514.         wsprintf ((LPSTR) szOut, "%s %d.%02.02d.%02.02d", (LPSTR) szIn,
  1515.                 GetRValue(msMCISAMVERSION), GetGValue(msMCISAMVERSION),
  1516.                 GetBValue(msMCISAMVERSION));
  1517.  
  1518.         SetDlgItemText (hdlg, IDST_VERSION, (LPSTR) szOut);
  1519.         return(TRUE);
  1520.         break;
  1521.  
  1522.     case WM_COMMAND:
  1523.  
  1524.         switch (wParam)
  1525.         {
  1526.  
  1527.         case IDPB_OK:
  1528.             EndDialog (hdlg, TRUE);
  1529.             break;
  1530.  
  1531.  
  1532.         default:
  1533.             // Message not processed
  1534.             return(FALSE);
  1535.         }
  1536.  
  1537.         // Message processed
  1538.         return(TRUE);
  1539.         break;
  1540.  
  1541.     case WM_CLOSE:
  1542.         EndDialog (hdlg, FALSE);
  1543.           break;
  1544.  
  1545.     default:
  1546.         // Message not processed
  1547.         return(FALSE);
  1548.  
  1549.     }
  1550.     return(FALSE);
  1551. }
  1552.  
  1553.  
  1554. /****************************************************************************
  1555.  
  1556.     Function:    msIsMoviePlaying ()        - local
  1557.  
  1558.     Desc:        Checks to see if we are playing the movie.
  1559.  
  1560.     Returns:    BOOL    TRUE            - We are playing the movie
  1561.                         FALSE           - We are not playing the movie
  1562.  
  1563. ****************************************************************************/
  1564.  
  1565. BOOL
  1566. msIsMoviePlaying (VOID)
  1567. {
  1568.     MCI_STATUS_PARMS    mciStatusParms;
  1569.     DWORD               dwError;
  1570.  
  1571.  
  1572.     // finds out the mode of the movie
  1573.     mciStatusParms.dwItem = MCI_STATUS_MODE;
  1574.  
  1575.     dwError = mciSendCommand (wDeviceID, MCI_STATUS,
  1576.                 (DWORD) MCI_STATUS_ITEM,
  1577.                 (DWORD) (LPSTR)(&mciStatusParms));
  1578.  
  1579.     if (dwError)
  1580.     {
  1581.         msDisplayMCIError (dwError);
  1582.         return FALSE;
  1583.     }
  1584.     else
  1585.     {
  1586.         if (mciStatusParms.dwReturn == MCI_MODE_PLAY)
  1587.         {
  1588.             return TRUE;
  1589.         }
  1590.     }
  1591.     return FALSE;
  1592. }
  1593.  
  1594.  
  1595. /****************************************************************************
  1596.  
  1597.     Function:    msFillWindowColor ()        - local
  1598.  
  1599.     Desc:        Fills the given window in the given color.
  1600.  
  1601.     Returns:    VOID    
  1602.                         
  1603.  
  1604. ****************************************************************************/
  1605.  
  1606. VOID
  1607. msFillWindowColor (HWND hwndPlay, int nIndex)
  1608. {
  1609.     HDC         hdcPlay;
  1610.     POINT       ptTopLeft;
  1611.     RECT        rc;
  1612.  
  1613.     GetClientRect (hwndPlay, &rc);
  1614.  
  1615.     // Get DC of the window and fill it with the given brush index
  1616.     hdcPlay = GetDC (hwndPlay);
  1617.     FillRect (hdcPlay, &rc, GetStockObject (nIndex));
  1618.     ReleaseDC (hwndPlay, hdcPlay);
  1619. }
  1620.  
  1621.  
  1622. /****************************************************************************
  1623.  
  1624.     Function:    msSetDlgItemCaps ()        - local
  1625.  
  1626.     Desc:        Determines where the given Item is supported or not.
  1627.                 Fills the given dialog.
  1628.  
  1629.     Returns:    VOID    
  1630.                         
  1631.  
  1632. ****************************************************************************/
  1633.  
  1634. VOID
  1635. msSetDlgItemCaps (
  1636. HWND hdlg,      // handle to the DevCaps dialog
  1637. DWORD dwItem,   // the item to check
  1638. WORD wId)       // the string ID of dwItem
  1639. {
  1640.     MCI_GETDEVCAPS_PARMS     mciGetDevCapsParms;
  1641.     DWORD       dwResult;
  1642.     char        szResult[msMAX];
  1643.  
  1644.     mciGetDevCapsParms.dwItem = dwItem;
  1645.     mciSendCommand (wDeviceID, MCI_GETDEVCAPS,
  1646.                 MCI_WAIT | MCI_GETDEVCAPS_ITEM,
  1647.                 (DWORD) (LPVOID) &mciGetDevCapsParms);
  1648.  
  1649.  
  1650.     if (mciGetDevCapsParms.dwReturn)
  1651.     {
  1652.         LoadString (hMainInstance,IDS_SUPPORTED_FUNCTION,
  1653.                         szResult, sizeof(szResult)-1);               
  1654.     }
  1655.     else
  1656.     {
  1657.         LoadString (hMainInstance,IDS_UNSUPPORTED_FUNCTION,
  1658.                         szResult, sizeof(szResult)-1);               
  1659.  
  1660.     }
  1661.     SetWindowText (GetDlgItem (hdlg, wId), szResult);
  1662. }
  1663.