home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
cyber.net 2
/
cybernet2.ISO
/
qtw111
/
mplayer
/
framewnd.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-11
|
40KB
|
1,074 lines
// ---------------------------------------------------------------------
//
// FrameWnd.c - Movie Player - QuickTime for Windows
//
// Version 1.0
//
// (c) 1988-1992 Apple Computer, Inc. All Rights Reserved.
//
// ---------------------------------------------------------------------
// Includes
// --------
#include <Windows.H> // Required by Windows
#include <commdlg.h> // Header file for common dlgs
#include <dlgs.h> // Header file for common dlgs ids
#include <cderr.h> // Header file for error ids
#include <memory.h> // For memset()
#include <shellapi.h> // Required for drag and drop
#include <qtole.h> // Interface to qtole dll's
#include "common.h" // Interface to common.c
#include "player.h" // Interface to other *.c files
#include "player.hr" // Defines used in *.rc files
// Message-Persistent Data
// -----------------------
static struct // Hungarian notation: g
{ HWND hwndClient; // MDI client window
WORD wNumMovies; // Number of movie wnds
BOOL bUserAbortPrint; // User abort print flag
HWND hwndCancelPrt; // Handle of print cancel dlg
HBITMAP hAboutBitmap; // Temp static storage of bitmap
// displayed in about dialogs
WORD wTileCascadeArrange; // Indicates tiling, cascading or
// icon arrange
BOOL bIconized; // TRUE while frame wnd is iconized
BOOL bRestoring; // TRUE if restoring iconized frame wnd
} g;
// Exported callback functions
// ----------------------------
BOOL __export CALLBACK AboutDlgProc (HWND, UINT, WPARAM, LPARAM);
BOOL __export CALLBACK CloseEnumProc (HWND, LPARAM);
BOOL __export CALLBACK MovieEnumProc (HWND, LPARAM);
BOOL __export CALLBACK PrintCancelDlgProc (HWND, UINT, WPARAM, LPARAM);
int __export CALLBACK PrintAbortProc (HDC, int);
UINT __export CALLBACK PrintDlgHookProc (HWND, UINT, WPARAM, LPARAM);
// Internal Function Declarations
// ------------------------------
static LONG NEAR PlayerFrameCreate (HWND);
static LONG NEAR PlayerFileCommands (HWND, WPARAM, WORD);
static LONG NEAR PlayerWindowCommands (HWND, WPARAM, WORD);
static LONG NEAR PlayerHelpCommands (HWND, WPARAM, WORD);
static LONG NEAR LaunchMovieWnd (LPSTR, LPSTR);
static VOID NEAR PlayerEnableMenus (HWND, BOOL);
static VOID NEAR TellUserCommonDlgError (DWORD);
static LONG NEAR ProcessDroppedFiles (HWND, WPARAM);
static VOID NEAR DestroyHelpInstance (HWND);
// -----------------------------------------------------------------------
// Function: PlayerFrameWndProc - Player Frame Window Procedure
// --------------------------------------------------------------------
// Parameters: As required by Microsoft Windows
//
// Returns: Via DefFrameProc
// --------------------------------------------------------------------
LONG __export CALLBACK PlayerFrameWndProc
(HWND hwndFrame, UINT message, WPARAM wParam, LPARAM lParam)
{
WNDENUMPROC lpfnEnumMovies; // -> callback funcion for
// enumeration of movies
HWND hwndMovie; // Temp handle of active movie wnd
LPQTOLE_OLEDATA lpOleData; // -> ole data
switch( message ) {
case WM_CREATE:
return PlayerFrameCreate( hwndFrame );
case WM_PALETTECHANGED:
if( g.wNumMovies &&
( lpfnEnumMovies = (WNDENUMPROC) MakeProcInstance
( (FARPROC) MovieEnumProc, PlayerQueryInstance()))) { // Tell the movie wnds to repaint
EnumChildWindows( g.hwndClient, lpfnEnumMovies,
(LPARAM) message);
FreeProcInstance( (FARPROC) lpfnEnumMovies );
}
return 0L;
case WM_SIZE:
if( wParam == SIZE_MINIMIZED ) {
g.bIconized = TRUE;
g.bRestoring = FALSE;
}
else if( g.bIconized &&
(( wParam == SIZE_RESTORED ) ||
( wParam == SIZE_MAXIMIZED ))) {
g.bIconized = FALSE;
g.bRestoring = TRUE;
}
if( g.wNumMovies &&
( lpfnEnumMovies = (WNDENUMPROC) MakeProcInstance
( (FARPROC) MovieEnumProc, PlayerQueryInstance()))) { // Tell the movie wnds to reset their grow box bounds rect
EnumChildWindows( g.hwndClient, lpfnEnumMovies,
(LPARAM) message);
FreeProcInstance( (FARPROC) lpfnEnumMovies );
}
if( g.bRestoring ) {
g.bRestoring = FALSE;
}
break; // break to DefFrameProc
case WM_INITMENUPOPUP:
// Set check marks and enable menu items in popups
if( !(BOOL) HIWORD( lParam ) &&
( hwndMovie = (HWND) SendMessage
( g.hwndClient, WM_MDIGETACTIVE, 0, 0l )) &&
IsWindow( hwndMovie ))
SendMessage( hwndMovie, WM_PLAYER_INITPOPUPS, wParam, lParam );
return 0L;
case WM_COMMAND:
switch( wParam ) {
case PLAYER_FILE_OPEN: // file menu popup
case PLAYER_FILE_CLOSE:
case PLAYER_FILE_PRTSETUP:
case PLAYER_FILE_PRINT:
case PLAYER_FILE_EXIT:
return PlayerFileCommands
( hwndFrame, wParam, HIWORD (lParam));
case PLAYER_WINDOW_TILE: // window menu popup
case PLAYER_WINDOW_CASCADE:
case PLAYER_WINDOW_ARRANGE:
return PlayerWindowCommands
( hwndFrame, wParam, HIWORD (lParam));
case PLAYER_HELP_PLAYERHELP: // help menu popup
case PLAYER_HELP_USINGHELP:
case PLAYER_HELP_ABOUTPLAYER:
return PlayerHelpCommands
( hwndFrame, wParam, HIWORD( lParam ));
default:
if( ( hwndMovie = (HWND) SendMessage
( g.hwndClient, WM_MDIGETACTIVE, 0, 0L )) &&
IsWindow( hwndMovie ))
SendMessage( hwndMovie, WM_COMMAND, wParam, lParam );
break; // break to DefFrameProc
}
break;
// WM_USER messages
case WM_PLAYER_CMDLINE:
return LaunchMovieWnd( (LPSTR) lParam, NULL );
case WM_PLAYER_MOVIEDELETED:
// Decrement movie count. This is incremented in LaunchMovieWnd
// when movie is created
if( --g.wNumMovies <= 0 )
PlayerEnableMenus( hwndFrame, FALSE );
return 0L;
// These next messages are posted by the ole callback function in MovieUtl.c
case WM_PLAYER_OLE_OPTIONSDLG:
PlayerGetOptions( NULL, (LPQTOLE_OPTIONSMOVIE) lParam );
return 0L;
case WM_PLAYER_OLE_PLAYOBJECT:
QTOLE_PlayObject( PlayerQueryOleData(), lParam );
return 0L;
// end WM_USER messages
// Standard drag and drop processing. Allows for multiple movies but
// does not worry about position of drop
case WM_DROPFILES:
return ProcessDroppedFiles( hwndFrame, wParam );
case WM_QUERYENDSESSION:
case WM_CLOSE:
if( g.wNumMovies &&
( lpfnEnumMovies = (WNDENUMPROC) MakeProcInstance
( (FARPROC) CloseEnumProc, PlayerQueryInstance()))) { // Give all movies a chance to stop the close
EnumChildWindows( g.hwndClient, lpfnEnumMovies, 0L );
FreeProcInstance( (FARPROC) lpfnEnumMovies );
// If someone didn't want to close, don't kill the app
if( NULL != GetWindow( g.hwndClient, GW_CHILD ))