home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
cyber.net 2
/
cybernet2.ISO
/
qtw111
/
pviewer
/
framewnd.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-11
|
38KB
|
1,016 lines
// ---------------------------------------------------------------------
//
// FrameWnd.c - Picture Viewer - QuickTime for Windows
//
// Version 1.0
//
// (c) 1988-1992 Apple Computer, Inc. All Rights Reserved.
//
// ---------------------------------------------------------------------
// Includes
// --------
#define NOMINMAX
#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> // Needed for memset() function
#include <shellapi.h> // Drag and drop stuff
#include <qtole.h> // Interface to qtole dll
#include "common.h" // Interface to common.c
#include "viewer.h" // Interface to other *.c files
#include "viewer.hr" // Defines used in *.rc files
#include "picture.h" // Interface to other *.c files
// Message-Persistent Data
// -----------------------
static struct // Hungarian notation: g
{ HWND hwndClient; // MDI client window
WORD wNumPictures; // Number of picture 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
} g;
// Exported callback functions
// ----------------------------
BOOL __export CALLBACK AboutDlgProc (HWND, UINT, WPARAM, LPARAM);
BOOL __export CALLBACK CloseEnumProc (HWND, LPARAM);
BOOL __export CALLBACK PaletteEnumProc (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 ViewerFrameCreate (HWND);
static LONG NEAR ViewerFileCommands (HWND, WPARAM, WORD);
static LONG NEAR ViewerWindowCommands (HWND, WPARAM, WORD);
static LONG NEAR ViewerHelpCommands (HWND, WPARAM, WORD);
static LONG NEAR LaunchPictureWnd (LPSTR, LPSTR);
static VOID NEAR ViewerEnableMenus (HWND, BOOL);
static VOID NEAR TellUserCommonDlgError (DWORD);
static LONG NEAR ProcessDroppedFiles (HWND, WPARAM );
static VOID NEAR DestroyHelpInstance (HWND);
// -----------------------------------------------------------------------
// Function: ViewerFrameWndProc - Viewer Frame Window Procedure
// --------------------------------------------------------------------
// Parameters: As required by Microsoft Windows
//
// Returns: Via DefFrameProc
// --------------------------------------------------------------------
LONG __export CALLBACK ViewerFrameWndProc
(HWND hwndFrame, UINT message, WPARAM wParam, LPARAM lParam)
{
WNDENUMPROC lpfnEnumPictures; // -> callback funcion for
// enumeration of pictures
HWND hwndPicture; // Temp handle of active picture wnd
LPQTOLE_OLEDATA lpOleData; // -> to OLE data
switch( message ) {
case WM_CREATE:
return ViewerFrameCreate( hwndFrame );
case WM_PALETTECHANGED:
if( g.wNumPictures &&
( lpfnEnumPictures = (WNDENUMPROC) MakeProcInstance
( (FARPROC) PaletteEnumProc, ViewerQueryInstance()))) {
StoreCurrentSystemPalette( NULL );
// Tell the picture wnds to repaint themselves
EnumChildWindows( g.hwndClient, lpfnEnumPictures,
(LPARAM) wParam);
FreeProcInstance( (FARPROC) lpfnEnumPictures );
}
return 0L;
case WM_INITMENUPOPUP:
// Set check marks and enable menu items in popups
if( !(BOOL) HIWORD( lParam ) &&
( hwndPicture = (HWND) SendMessage
( g.hwndClient, WM_MDIGETACTIVE, 0, 0L )) &&
IsWindow( hwndPicture ))
SendMessage( hwndPicture,
WM_VIEWER_INITPOPUPS, wParam, lParam );
return 0L;
case WM_COMMAND:
switch( wParam ) {
case VIEWER_FILE_OPEN: // file menu popup
case VIEWER_FILE_CLOSE:
case VIEWER_FILE_PRTSETUP:
case VIEWER_FILE_PRINT:
case VIEWER_FILE_EXIT:
return ViewerFileCommands
( hwndFrame, wParam, HIWORD (lParam));
case VIEWER_WINDOW_TILE: // window menu popup
case VIEWER_WINDOW_CASCADE:
case VIEWER_WINDOW_ARRANGE:
return ViewerWindowCommands
( hwndFrame, wParam, HIWORD (lParam));
case VIEWER_HELP_VIEWERHELP: // help menu popup
case VIEWER_HELP_USINGHELP:
case VIEWER_HELP_ABOUTVIEWER:
return ViewerHelpCommands
( hwndFrame, wParam, HIWORD (lParam));
default:
if( ( hwndPicture = (HWND) SendMessage
( g.hwndClient, WM_MDIGETACTIVE, 0, 0L )) &&
IsWindow( hwndPicture ))
SendMessage( hwndPicture,
WM_COMMAND, wParam, lParam );
break; // break to DefFrameProc
}
break;
// WM_USER messages
case WM_VIEWER_CMDLINE:
return LaunchPictureWnd( (LPSTR) lParam, NULL );
case WM_VIEWER_PICTUREDELETED:
// Decrement picture count. This is incremented in LaunchPictureWnd
// when picture is created
if( --g.wNumPictures <= 0 )
ViewerEnableMenus( hwndFrame, FALSE );
return 0L;
// These next messages are posted by the ole callback function in PictUtl.c
case WM_VIEWER_OLE_OPTIONSDLG:
ViewerGetOptions( NULL, (LPQTOLE_OPTIONSPICTURE) lParam );
return 0L;
case WM_VIEWER_OLE_PLAYOBJECT:
QTOLE_PlayObject( ViewerQueryOleData(), lParam );
return 0L;
// end WM_USER messages
// Standard drag and drop processing. Allows for multiple pictures but
// does not worry about position of drop
case WM_DROPFILES:
return ProcessDroppedFiles( hwndFrame, wParam );
case WM_QUERYENDSESSION:
case WM_CLOSE:
if( g.wNumPictures &&
( lpfnEnumPictures = (WNDENUMPROC) MakeProcInstance
( (FARPROC) CloseEnumProc, ViewerQueryInstance()))) { // Give all pictures a chance to stop the close
EnumChildWindows( g.hwndClient, lpfnEnumPictures, 0L );
FreeProcInstance( (FARPROC) lpfnEnumPictures );
// If someone didn't want to close, don't kill the app
if( NULL != GetWindow( g.hwndClient, GW_CHILD ))
return 0L;
}
// Tell qtole.dll that we are closing the server
// Don't close if QTOLE_ClosingServerWnd returns FALSE;
if( ( lpOleData = ViewerQueryOleData()) &&
lpOleData->lpqtoleServer &&
!QTOLE_ClosingServerWnd( lpOleData, message ))
return 0L;
break; // break to DefFrameProc
case WM_NCDESTROY:
DragAcceptFiles( hwndFrame, FALSE );
// Destroy help instance
DestroyHelpInstance( hwndFrame );
// NULL the global hwnds in viewmain.c
ViewerNoMoreWindow();
PostQuitMessage( 0 );
break;
}
return DefFrameProc
( hwndFrame, g.hwndClient, message, wParam, lParam );
}
// Function: ViewerFrameCreate - process WM_CREATE message
// ------------------------------------------------------------------