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

  1.  
  2. // ---------------------------------------------------------------------
  3. //
  4. // FrameWnd.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. // Includes
  14. // --------
  15. #include <Windows.H>  // Required by Windows
  16. #include <commdlg.h>  // Header file for common dlgs
  17. #include <dlgs.h>     // Header file for common dlgs ids
  18. #include <cderr.h>    // Header file for error ids
  19. #include <memory.h>   // For memset()
  20. #include <shellapi.h> // Required for drag and drop
  21.  
  22. #include <qtole.h> // Interface to qtole dll's
  23.  
  24. #include "common.h" // Interface to common.c
  25.  
  26. #include "player.h"  // Interface to other *.c files
  27. #include "player.hr" // Defines used in *.rc files
  28.  
  29.  
  30. // Message-Persistent Data
  31. // -----------------------
  32. static struct // Hungarian notation: g
  33.   { HWND      hwndClient;          // MDI client window
  34.     WORD      wNumMovies;          // Number of movie wnds
  35.     BOOL      bUserAbortPrint;     // User abort print flag
  36.     HWND      hwndCancelPrt;       // Handle of print cancel dlg
  37.     HBITMAP   hAboutBitmap;        // Temp static storage of bitmap
  38.                                    // displayed in about dialogs
  39.     WORD      wTileCascadeArrange; // Indicates tiling, cascading or
  40.                                    // icon arrange
  41.     BOOL      bIconized;           // TRUE while frame wnd is iconized
  42.     BOOL      bRestoring;          // TRUE if restoring iconized frame wnd
  43.   } g;
  44.  
  45.  
  46. // Exported callback functions
  47. // ----------------------------
  48. BOOL __export CALLBACK AboutDlgProc       (HWND, UINT, WPARAM, LPARAM);
  49. BOOL __export CALLBACK CloseEnumProc      (HWND, LPARAM);
  50. BOOL __export CALLBACK MovieEnumProc      (HWND, LPARAM);
  51. BOOL __export CALLBACK PrintCancelDlgProc (HWND, UINT, WPARAM, LPARAM);
  52. int  __export CALLBACK PrintAbortProc     (HDC, int);
  53. UINT __export CALLBACK PrintDlgHookProc   (HWND, UINT, WPARAM, LPARAM);
  54.  
  55. // Internal Function Declarations
  56. // ------------------------------
  57. static LONG NEAR PlayerFrameCreate       (HWND);
  58. static LONG NEAR PlayerFileCommands      (HWND, WPARAM, WORD);
  59. static LONG NEAR PlayerWindowCommands    (HWND, WPARAM, WORD);
  60. static LONG NEAR PlayerHelpCommands      (HWND, WPARAM, WORD);
  61. static LONG NEAR LaunchMovieWnd          (LPSTR, LPSTR);
  62. static VOID NEAR PlayerEnableMenus       (HWND, BOOL);
  63. static VOID NEAR TellUserCommonDlgError  (DWORD);
  64. static LONG NEAR ProcessDroppedFiles     (HWND, WPARAM);
  65. static VOID NEAR DestroyHelpInstance     (HWND);
  66.  
  67. // -----------------------------------------------------------------------
  68.  
  69.  
  70. // Function: PlayerFrameWndProc - Player Frame Window Procedure
  71. // --------------------------------------------------------------------
  72. // Parameters: As required by Microsoft Windows
  73. //
  74. // Returns:    Via DefFrameProc
  75. // --------------------------------------------------------------------
  76. LONG __export CALLBACK PlayerFrameWndProc
  77.     (HWND hwndFrame, UINT message, WPARAM wParam, LPARAM lParam)
  78.  
  79. {
  80.     WNDENUMPROC       lpfnEnumMovies; // -> callback funcion for
  81.                                       // enumeration of movies
  82.     HWND              hwndMovie;      // Temp handle of active movie wnd
  83.     LPQTOLE_OLEDATA   lpOleData;      // -> ole data
  84.  
  85.     switch( message ) {
  86.         case WM_CREATE:
  87.             return PlayerFrameCreate( hwndFrame );
  88.  
  89.         case WM_PALETTECHANGED:
  90.             if( g.wNumMovies &&
  91.                 ( lpfnEnumMovies = (WNDENUMPROC) MakeProcInstance
  92.                 ( (FARPROC) MovieEnumProc, PlayerQueryInstance()))) { // Tell the movie wnds to repaint
  93.                 EnumChildWindows( g.hwndClient, lpfnEnumMovies,
  94.                     (LPARAM) message);
  95.                 FreeProcInstance( (FARPROC) lpfnEnumMovies );
  96.             }
  97.  
  98.             return 0L;
  99.  
  100.         case WM_SIZE:
  101.             if( wParam == SIZE_MINIMIZED ) {
  102.                 g.bIconized  = TRUE;
  103.                 g.bRestoring = FALSE;
  104.             }
  105.             else if( g.bIconized && 
  106.                 (( wParam == SIZE_RESTORED ) ||
  107.                 ( wParam == SIZE_MAXIMIZED ))) {
  108.                 g.bIconized  = FALSE;
  109.                 g.bRestoring = TRUE;
  110.             }
  111.  
  112.             if( g.wNumMovies &&
  113.                 ( lpfnEnumMovies = (WNDENUMPROC) MakeProcInstance
  114.                 ( (FARPROC) MovieEnumProc, PlayerQueryInstance()))) { // Tell the movie wnds to reset their grow box bounds rect
  115.                 EnumChildWindows( g.hwndClient, lpfnEnumMovies, 
  116.                     (LPARAM) message);
  117.                 FreeProcInstance( (FARPROC) lpfnEnumMovies );
  118.             }
  119.  
  120.             if( g.bRestoring ) {
  121.                 g.bRestoring = FALSE;
  122.             }
  123.  
  124.             break; // break to DefFrameProc
  125.  
  126.  
  127.         case WM_INITMENUPOPUP:
  128.             // Set check marks and enable menu items in popups
  129.             if( !(BOOL) HIWORD( lParam ) &&
  130.                 ( hwndMovie = (HWND) SendMessage
  131.                 ( g.hwndClient, WM_MDIGETACTIVE, 0, 0l )) &&
  132.                 IsWindow( hwndMovie ))
  133.                 SendMessage( hwndMovie, WM_PLAYER_INITPOPUPS, wParam, lParam );
  134.  
  135.             return 0L;
  136.  
  137.         case WM_COMMAND:
  138.             switch( wParam ) {
  139.                 case PLAYER_FILE_OPEN: // file menu popup
  140.                 case PLAYER_FILE_CLOSE:
  141.                 case PLAYER_FILE_PRTSETUP:
  142.                 case PLAYER_FILE_PRINT:
  143.                 case PLAYER_FILE_EXIT:
  144.                     return PlayerFileCommands
  145.                         ( hwndFrame, wParam, HIWORD (lParam));
  146.  
  147.                 case PLAYER_WINDOW_TILE: // window menu popup
  148.                 case PLAYER_WINDOW_CASCADE:
  149.                 case PLAYER_WINDOW_ARRANGE:
  150.                     return PlayerWindowCommands
  151.                         ( hwndFrame, wParam, HIWORD (lParam));
  152.  
  153.  
  154.                 case PLAYER_HELP_PLAYERHELP: // help menu popup
  155.                 case PLAYER_HELP_USINGHELP:
  156.                 case PLAYER_HELP_ABOUTPLAYER:
  157.                     return PlayerHelpCommands
  158.                         ( hwndFrame, wParam, HIWORD( lParam ));
  159.  
  160.                 default:
  161.                     if( ( hwndMovie = (HWND) SendMessage
  162.                         ( g.hwndClient, WM_MDIGETACTIVE, 0, 0L )) &&
  163.                         IsWindow( hwndMovie ))
  164.                         SendMessage( hwndMovie, WM_COMMAND, wParam, lParam );
  165.  
  166.                     break; // break to DefFrameProc
  167.             } 
  168.  
  169.             break;
  170.  
  171.         // WM_USER messages
  172.  
  173.         case WM_PLAYER_CMDLINE:
  174.             return LaunchMovieWnd( (LPSTR) lParam, NULL );
  175.  
  176.         case WM_PLAYER_MOVIEDELETED:
  177.             // Decrement movie count. This is incremented in LaunchMovieWnd
  178.             // when movie is created
  179.             if( --g.wNumMovies <= 0 )
  180.                 PlayerEnableMenus( hwndFrame, FALSE );
  181.             return 0L;
  182.  
  183.         // These next messages are posted by the ole callback function in MovieUtl.c
  184.         case WM_PLAYER_OLE_OPTIONSDLG:
  185.             PlayerGetOptions( NULL, (LPQTOLE_OPTIONSMOVIE) lParam );
  186.             return 0L;
  187.  
  188.         case WM_PLAYER_OLE_PLAYOBJECT:
  189.             QTOLE_PlayObject( PlayerQueryOleData(), lParam );
  190.             return 0L;
  191.  
  192.         // end WM_USER messages
  193.  
  194.  
  195.         // Standard drag and drop processing. Allows for multiple movies but
  196.         // does not worry about position of drop
  197.         case WM_DROPFILES:
  198.             return ProcessDroppedFiles( hwndFrame, wParam );
  199.  
  200.         case WM_QUERYENDSESSION:
  201.         case WM_CLOSE:
  202.             if( g.wNumMovies &&
  203.                 ( lpfnEnumMovies = (WNDENUMPROC) MakeProcInstance
  204.                 ( (FARPROC) CloseEnumProc, PlayerQueryInstance()))) { // Give all movies a chance to stop the close
  205.                 EnumChildWindows( g.hwndClient, lpfnEnumMovies, 0L );
  206.                 FreeProcInstance( (FARPROC) lpfnEnumMovies );
  207.  
  208.                 // If someone didn't want to close, don't kill the app
  209.                 if( NULL != GetWindow( g.hwndClient, GW_CHILD ))
  210.