home *** CD-ROM | disk | FTP | other *** search
/ cyber.net 2 / cybernet2.ISO / qtw111 / mplayer / movieutl.c < prev    next >
C/C++ Source or Header  |  1994-01-11  |  27KB  |  699 lines

  1.  
  2. // ---------------------------------------------------------------------
  3. //
  4. // MovieUtl.c - Movie Player - QuickTime for Windows
  5. //
  6. //              Version 1.0
  7. //
  8. //              (c) 1988-1992 Apple Computer, Inc. All Rights Reserved.
  9. //
  10. // ---------------------------------------------------------------------
  11.  
  12.  
  13.  
  14. // Includes
  15. // --------
  16. #include <Windows.H> // Required by Windows
  17. #include <qtw.h>     // Interface to QuickTime
  18. #include <qtole.h>   // Interface to qtole dll
  19. #include <string.h>  // Standard "C"
  20.  
  21. #include "common.h" // Interface to common.c
  22.  
  23. #include "player.h"  // Interface to other *.c files
  24. #include "player.hr" // Defines used in *.rc files
  25.  
  26. // Constants
  27. // ---------
  28. #define  OPTIONSPROP   "MovieOptionsProp"
  29.  
  30.  
  31. // typedefs
  32. // --------
  33. typedef struct _tagWORKOPTIONS {
  34.     QTOLE_OPTIONSMOVIE      SaveOptions;
  35.     LPQTOLE_OPTIONSMOVIE    lpOptions;
  36.     HLOCAL                  hmem;
  37.    } WORKOPTIONS;
  38. typedef WORKOPTIONS NEAR * NPWORKOPTIONS;
  39.  
  40.  
  41. // Exported callback functions
  42. // ----------------------------
  43. BOOL __export CALLBACK GetOptionsDlgProc    (HWND, UINT, WPARAM, LPARAM);
  44.  
  45. // Internal Function Declarations
  46. // ------------------------------
  47. static VOID    NEAR    SetDlgForOptions       (HWND, LPQTOLE_OPTIONSMOVIE);
  48. static VOID    NEAR    GetCurrentDlgSettings  (HWND, LPQTOLE_OPTIONSMOVIE);
  49. static VOID    NEAR    SaveOptionsAsDefault   (LPQTOLE_OPTIONSMOVIE);
  50.  
  51.  
  52. // Function: PlayerGetOptions - Opens the options dialog
  53. // --------------------------------------------------------------------
  54. // Parameters: HWND                    hwndParent     HWND of dialog parent
  55. //             LPQTOLE_OPTIONSMOVIE    lpOptions      -> options struct
  56. //
  57. // Returns:    LONG                    0L if OK
  58. // --------------------------------------------------------------------
  59. BOOL FAR PlayerGetOptions( HWND hwndParent, LPQTOLE_OPTIONSMOVIE lpOptions )
  60.  
  61. {
  62.     BOOL         bChangedOptions = FALSE;
  63.     DLGPROC      lpDlgProc;
  64.  
  65.     if( lpDlgProc = (DLGPROC) MakeProcInstance
  66.         ( (FARPROC) GetOptionsDlgProc, PlayerQueryInstance())) {
  67.         bChangedOptions = (BOOL) DialogBoxParam( PlayerQueryResources(),
  68.             MAKEINTRESOURCE( PLAYER_DLG_OPTIONS ),
  69.             hwndParent? hwndParent: GetActiveWindow(),
  70.             lpDlgProc, (LPARAM) lpOptions );
  71.         FreeProcInstance( (FARPROC) lpDlgProc );
  72.  
  73.         // Null hwndParent indicates that dlg was started by qtole message
  74.         // with no open movie. In this case tell QTOle.dll that dialog has
  75.         // been closed. Must do this even if options are not changed and
  76.         // must return the same pointer to lpOptions as input argument to
  77.         // this function. When qtole opens dialog for open movie, normal
  78.         // closing will updata options
  79.         if( !hwndParent )
  80.             QTOLE_ClosedOptionsDlg( PlayerQueryOleData(),
  81.             (LPQTOLE_OPTIONS) lpOptions, bChangedOptions );
  82.     }
  83.     else {
  84.         CommonTellUser( PlayerQueryResources(),
  85.             PLAYER_STRING_NOMEMORY, NULL, MB_OK );
  86.     }
  87.  
  88.     return bChangedOptions;
  89. }
  90.  
  91.  
  92. // Function: GetOptionsDlgProc - Get options dialog proc
  93. // --------------------------------------------------------------------
  94. // Parameters: As required by Microsoft Windows
  95. //
  96. // Returns:    As required by Microsoft Windows
  97. // --------------------------------------------------------------------
  98. BOOL __export CALLBACK GetOptionsDlgProc
  99.     ( HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam )
  100.  
  101. {
  102.     NPWORKOPTIONS           pwoWorkOptions;
  103.     HLOCAL                  hmem;
  104.     BOOL                    bOptionsChanged;
  105.     BOOL                    bChecked;
  106.     LPQTOLE_OPTIONSMOVIE    lpOptions;
  107.  
  108.     switch( message ) {
  109.         case WM_INITDIALOG:
  110.             lpOptions = (LPQTOLE_OPTIONSMOVIE) lParam;
  111.  
  112.             hmem = LocalAlloc( LHND, sizeof( WORKOPTIONS ));
  113.             pwoWorkOptions = (NPWORKOPTIONS) LocalLock( hmem );
  114.             pwoWorkOptions->hmem = hmem;
  115.             pwoWorkOptions->SaveOptions = *lpOptions;
  116.             pwoWorkOptions->lpOptions   = lpOptions;
  117.  
  118.             SetProp( hdlg, OPTIONSPROP, (HANDLE) pwoWorkOptions );
  119.  
  120.             SetDlgForOptions( hdlg, pwoWorkOptions->lpOptions );
  121.  
  122.             SetDlgItemText( hdlg, EDIT_OPTIONS_CAPTION,
  123.                 pwoWorkOptions->lpOptions->szCaption );
  124.  
  125.             return TRUE;
  126.  
  127.         case WM_COMMAND:
  128.             switch( wParam  ) {
  129.                 case IDOK:
  130.                     pwoWorkOptions = (NPWORKOPTIONS) GetProp( hdlg, OPTIONSPROP );
  131.                     GetCurrentDlgSettings( hdlg, pwoWorkOptions->lpOptions );
  132.  
  133.                     bOptionsChanged
  134.                         = (_fmemcmp( pwoWorkOptions->lpOptions,
  135.                         &pwoWorkOptions->SaveOptions,
  136.                         sizeof( QTOLE_OPTIONSMOVIE )) != 0 );
  137.                     hmem = pwoWorkOptions->hmem;
  138.                     LocalUnlock( hmem );
  139.                     LocalFree( hmem );
  140.                     RemoveProp( hdlg, OPTIONSPROP );
  141.  
  142.                     EndDialog( hdlg, bOptionsChanged );
  143.                     return TRUE;
  144.  
  145.                 case IDCANCEL:
  146.                     pwoWorkOptions = (NPWORKOPTIONS) GetProp( hdlg, OPTIONSPROP );
  147.                     hmem = pwoWorkOptions->hmem;
  148.                     LocalUnlock( hmem );
  149.                     LocalFree( hmem );
  150.                     RemoveProp( hdlg, OPTIONSPROP );
  151.  
  152.                     EndDialog( hdlg, FALSE  );
  153.                     return TRUE;
  154.  
  155.                 case EDIT_OPTIONS_SHOWMC:
  156.                     bChecked = IsDlgButtonChecked( hdlg, EDIT_OPTIONS_SHOWMC );
  157.                     EnableWindow( GetDlgItem( hdlg, EDIT_OPTIONS_CAPTION_TEXT ),
  158.                         bChecked );
  159.                     EnableWindow( GetDlgItem( hdlg, EDIT_OPTIONS_CAPTION ),
  160.                         bChecked );
  161.                     return TRUE;
  162.  
  163.                 case EDIT_OPTIONS_COPYICON:
  164.                     bChecked = IsDlgButtonChecked( hdlg, EDIT_OPTIONS_COPYICON );
  165.                     EnableWindow( GetDlgItem( hdlg,
  166.                         EDIT_OPTIONS_SHOWTITLEBAR ), bChecked );
  167.                     if( !bChecked )
  168.                         CheckDlgButton( hdlg, EDIT_OPTIONS_SHOWTITLEBAR, TRUE );
  169.                     return TRUE;
  170.  
  171.                 case EDIT_OPTIONS_SAVEASDEF:
  172.                     pwoWorkOptions = (NPWORKOPTIONS) GetProp( hdlg, OPTIONSPROP );
  173.                     GetCurrentDlgSettings( hdlg, pwoWorkOptions->lpOptions );
  174.                     SaveOptionsAsDefault( pwoWorkOptions->lpOptions );
  175.                     return TRUE;
  176.  
  177.                 case EDIT_OPTIONS_RESTRDEF:
  178.                     pwoWorkOptions = (NPWORKOPTIONS) GetProp( hdlg, OPTIONSPROP );
  179.                     PlayerGetDefaultOptions( pwoWorkOptions->lpOptions );
  180.                     SetDlgForOptions( hdlg, pwoWorkOptions->lpOptions );
  181.                     return FALSE;
  182.  
  183.                 default:
  184.                     return FALSE;
  185.             }
  186.             return TRUE;
  187.  
  188.         default:
  189.             return FALSE;
  190.     }
  191.  
  192.     return FALSE;
  193. }
  194.  
  195.  
  196. // Function: QTOLEServerCallBack - Server callback used by qtole.dll to
  197. //                                 send commands to the server
  198. // --------------------------------------------------------------------
  199. // Parameters: UINT                      uMessage
  200. //             WPARAM                    wParam
  201. //             LPARAM                    lParam
  202. //             LPQTOLE_OPTIONSMOVIE      lpOptions
  203. //
  204. //
  205. // Returns:    QTOLE_ERR        QTOLE_OK if OK
  206. // --------------------------------------------------------------------
  207. QTOLE_ERR __export CALLBACK QTOLEServerCallBack
  208.     ( UINT uMessage, WPARAM wParam, LPARAM lParam,
  209.     LPQTOLE_OPTIONSMOVIE lpOptions )
  210.  
  211. {
  212.     HWND           hwndMovie;
  213.     NPMOVIEDATA    pMovieData;
  214.     RECT           rcMovie;
  215.     RECT           rcClient;
  216.     RECT           rcIntersect;
  217.  
  218.  
  219.     switch( uMessage ) {
  220.         case QTOLE_MSG_OPENOBJECT:
  221.             // Open a movie window
  222.             SendMessage( PlayerQueryFrameWindow(),
  223.