-
Notifications
You must be signed in to change notification settings - Fork 3
/
listing22.html
executable file
·1763 lines (1442 loc) · 53.1 KB
/
listing22.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<!-- BEGIN META TAG INFO -->
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="home" href="http://developer.apple.com/">
<link rel="find" href="http://developer.apple.com/search/">
<link rel="stylesheet" type="text/css" href="../../documentation/css/adcstyle.css" title="fonts">
<script language="JavaScript" src="../../documentation/js/adc.js" type="text/javascript"></script>
<!-- END META TAG INFO -->
<!-- BEGIN TITLE -->
<title>Play Movie with Controller - /Common Files/ComFramework.c</title>
<!-- END TITLE -->
<script language="JavaScript">
function JumpToNewPage() {
window.location=document.scpopupmenu.gotop.value;
return true;
}
</script>
</head>
<!-- BEGIN BODY OPEN -->
<body>
<!--END BODY OPEN -->
<!-- START CENTER OPEN -->
<center>
<!-- END CENTER OPEN -->
<!-- BEGIN LOGO AND SEARCH -->
<!--#include virtual="/includes/adcnavbar"-->
<!-- END LOGO AND SEARCH -->
<!-- START BREADCRUMB -->
<div id="breadcrumb">
<table width="680" border="0" cellpadding="0" cellspacing="0">
<tr>
<td scope="row"><img width="340" height="10" src="images/1dot.gif" alt=""></td>
<td><img width="340" height="10" src="images/1dot.gif" alt=""></td>
</tr>
<tr valign="middle">
<td align="left" colspan="2">
<a href="http://developer.apple.com/">ADC Home</a> > <a href="../../referencelibrary/index.html">Reference Library</a> > <a href="../../samplecode/index.html">Sample Code</a> > <a href="../../samplecode/QuickTime/index.html">QuickTime</a> > <a href="../../samplecode/QuickTime/idxMovieBasics-date.html">Movie Basics</a> > <A HREF="javascript:location.replace('index.html');">Play Movie with Controller</A> >
</td>
</tr>
<tr>
<td colspan="2" scope="row"><img width="680" height="35" src="images/1dot.gif" alt=""></td>
</tr>
</table>
</div>
<!-- END BREADCRUMB -->
<!-- START MAIN CONTENT -->
<!-- START TITLE GRAPHIC AND INTRO-->
<table width="680" border="0" cellpadding="0" cellspacing="0">
<tr align="left" valign="top">
<td><h1><div id="pagehead">Play Movie with Controller</div></h1></td>
</tr>
</table>
<!-- END TITLE GRAPHIC AND INTRO -->
<!-- START WIDE COLUMN -->
<table width="680" border="0" cellpadding="0" cellspacing="0">
<tr align="left" valign="top">
<td id="scdetails">
<h2>/Common Files/ComFramework.c</h2>
<form name="scpopupmenu" onSubmit="return false;" method=post>
<p><strong>View Source Code:</strong>
<select name="gotop" onChange="JumpToNewPage();" style="width:340px"><option selected value="ingnore">Select File</option>
<option value="listing1.html">/Application Files/ComApplication.c</option>
<option value="listing2.html">/Application Files/ComApplication.h</option>
<option value="listing3.html">/Application Files/ComResource.h</option>
<option value="listing4.html">/Clippings/Edit.c/SelectAll.txt</option>
<option value="listing5.html">/Clippings/Edit.c/SelectNone.txt</option>
<option value="listing6.html">/Clippings/Edit.c/SwitchEdit.txt</option>
<option value="listing7.html">/Clippings/Events.c/Draw.txt</option>
<option value="listing8.html">/Clippings/Events.c/MCActivate.txt</option>
<option value="listing9.html">/Clippings/Events.c/MCIsPlayerEvent.txt</option>
<option value="listing10.html">/Clippings/MCActionFilter.c/SwitchActions.txt</option>
<option value="listing11.html">/Clippings/OpenMovieInWindow.c/Dispose.txt</option>
<option value="listing12.html">/Clippings/OpenMovieInWindow.c/MCDoAction.txt</option>
<option value="listing13.html">/Clippings/OpenMovieInWindow.c/NewMovieFromFile.txt</option>
<option value="listing14.html">/Clippings/OpenMovieInWindow.c/OpenMovieFile.txt</option>
<option value="listing15.html">/Clippings/OpenMovieInWindow.c/SetMovieGWorld.txt</option>
<option value="listing16.html">/Clippings/OpenMovieInWindow.c/SetMovieProgressProc.txt</option>
<option value="listing17.html">/Clippings/SetupController.c/MCDoAction.txt</option>
<option value="listing18.html">/Clippings/SetupController.c/MCSetActionFilter.txt</option>
<option value="listing19.html">/Clippings/SetupController.c/NewMovieController.txt</option>
<option value="listing20.html">/Clippings/SetupController.c/Resize.txt</option>
<option value="listing21.html">/Clippings/SetupController.c/SetupController.txt</option>
<option value="listing22.html">/Common Files/ComFramework.c</option>
<option value="listing23.html">/Common Files/ComFramework.h</option>
<option value="listing24.html">/Common Files/MacFramework.c</option>
<option value="listing25.html">/Common Files/MacFramework.h</option>
<option value="listing26.html">/Common Files/MacPrefix.h</option>
<option value="listing27.html">/Common Files/plist:carb.r</option>
<option value="listing28.html">/Common Files/QTUtilities.c</option>
<option value="listing29.html">/Common Files/QTUtilities.h</option>
<option value="listing30.html">/Common Files/WinFramework.c</option>
<option value="listing31.html">/Common Files/WinFramework.h</option>
<option value="listing32.html">/Common Files/WinPrefix.h</option>
<option value="listing33.html">/Completed Lab/Edit.c</option>
<option value="listing34.html">/Completed Lab/Events.c</option>
<option value="listing35.html">/Completed Lab/MCActionFilter.c</option>
<option value="listing36.html">/Completed Lab/OpenMovieInWindow.c</option>
<option value="listing37.html">/Completed Lab/SetupController.c</option>
<option value="listing38.html">/Start Code/Edit.c</option>
<option value="listing39.html">/Start Code/Events.c</option>
<option value="listing40.html">/Start Code/MCActionFilter.c</option>
<option value="listing41.html">/Start Code/OpenMovieInWindow.c</option>
<option value="listing42.html">/Start Code/SetupController.c</option></select>
</p>
</form>
<p><strong><a href="Play_Movie_with_Controller.zip">Download Sample</a></strong> (“Play_Movie_with_Controller.zip”, 530.7K)<BR>
<strong><a href="Play_Movie_with_Controller.dmg">Download Sample</a></strong> (“Play_Movie_with_Controller.dmg”, 877.2K)</p>
<!--
<p><strong><a href="#">Download Sample</a></strong> (“filename.sit”, 500K)</p>
-->
</td>
</tr>
<tr>
<td scope="row"><img width="680" height="10" src="images/1dot.gif" alt=""><br>
<img height="1" width="680" src="images/1dot_919699.gif" alt=""><br>
<img width="680" height="20" src="images/1dot.gif" alt=""></td>
</tr>
<tr>
<td scope="row">
<!--googleon: index -->
<pre class="sourcecodebox">////////////// File: ComFramework.c//// Contains: Code for the QuickTime sample code framework that is common to both Macintosh and Windows.//// Written by: Tim Monroe// Based on the QTShell code written by Tim Monroe, which in turn was based on the MovieShell// code written by Kent Sandvik (Apple DTS). This current version is now very far removed from// MovieShell.//// Copyright: © 1999 by Apple Computer, Inc., all rights reserved.//// Change History (most recent first):// // <15> 03/02/00 rtm made changes to get things running under CarbonLib// <14> 02/16/00 rtm added QTFrame_GetWindowPtrFromWindowReference// <13> 01/19/00 rtm revised QTFrame_IsAppWindow (dialog windows no longer count as application// windows); added QTFrame_BuildFileTypeList and QTFrame_AddComponentFileTypes// to avoid calling GetMovieImporterForDataRef in QTFrame_FilterFiles; removed// the hard-coded file types// <12> 01/14/00 rtm added support for graphics files, using graphics importers// <11> 12/28/99 rtm added QTFrame_ConvertMacToWinRect and QTFrame_ConvertWinToMacRect// <10> 12/21/99 rtm hard-coded some file types into QTFrame_FilterFiles; if we let QuickTime// to do all the testing (using GetMovieImporterForDataRef), it takes too long// <9> 12/17/99 rtm added some code to QTFrame_SetMenuItemState to work around a problem that// appears under MacOS 8.5.1 (as far as I can tell...)// <8> 12/16/99 rtm added QTApp_HandleMenu calls to _HandleFileMenuItem and _HandleEditMenuItem// to allow the application-specific code to intercept menu item selections;// added QTFrame_FilterFiles// <7> 12/15/99 rtm added QTApp_Idle call to QTFrame_IdleMovieWindows// <6> 12/11/99 rtm added GetMenuState call to Windows portion of QTFrame_SetMenuItemLabel;// tweaked _SizeWindowToMovie to guard against NULL movie and/or controller// <5> 11/30/99 rtm added QTFrame_CloseMovieWindows// <4> 11/27/99 rtm added QTFrame_GetFileFilterUPP// <3> 11/17/99 rtm finished support for Navigation Services; added QTFrame_IdleMovieWindows// <2> 11/16/99 rtm begun support for Navigation Services// <1> 11/05/99 rtm first file//// This file contains several kinds of functions: (1) functions that use completely cross-platform APIs and// which therefore can be compiled and run for both Mac and Windows platforms with no changes whatsoever (a// good example of this is QTFrame_SaveAsMovieFile); (2) functions that are substantially the same on both// platforms but which require several short platform-dependent #ifdef TARGET_OS_ blocks (a good example of// this is QTFrame_AdjustMenus); (3) functions that retrieve data from framework-specific data structures (a// good example of this is QTFrame_GetWindowObjectFromWindow); (4) functions that provide a platform-neutral// interface to platform-specific operations (a good example of this is QTFrame_Beep). In a nutshell, this// file attempts to provide platform-independent services to its callers, typically functions in the files// MacFramework.c, WinFramework.c, and ComApplication.c.//// In general, you should not need to modify this file. Your application-specific code should usually be put// into the file ComApplication.c.////////////////////////// header files////////////#include "ComFramework.h"////////////// global variables////////////Rect gMCResizeBounds; // maximum size for any movie windowOSType *gValidFileTypes = NULL; // the list of file types that our application can open#if TARGET_OS_WIN32extern HWND ghWnd;extern HWND ghWndMDIClient;extern BOOL gWeAreSizingWindow;#endif#if TARGET_OS_MACextern Str255 gAppName;void QTFrame_HandleEvent (EventRecord *theEvent);#endif/////////////////////////////////////////////////////////////////////////////////////////////////////////////// Menu-handling functions.//// Use these functions to handle items in the File and Edit menus./////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// QTFrame_HandleFileMenuItem// Handle the specified File menu item.////////////void QTFrame_HandleFileMenuItem (WindowReference theWindow, UInt16 theMenuItem){ // give the application-specific code a chance to intercept the menu item selection if (QTApp_HandleMenu(theMenuItem)) return; switch (theMenuItem) { case IDM_FILENEW: QTFrame_CreateNewMovie(); break; case IDM_FILEOPEN: OpenMovieInWindow(NULL, NULL); break; case IDM_FILECLOSE: QTFrame_DestroyMovieWindow(theWindow); break; case IDM_FILESAVE: QTFrame_UpdateMovieFile(theWindow); break; case IDM_FILESAVEAS: QTFrame_SaveAsMovieFile(theWindow); break; case IDM_EXIT: QTFrame_QuitFramework(); break; default: break; } // switch (theMenuItem) }////////////// QTFrame_AdjustMenus // Adjust the application's menus.//// On Windows, the theWindow parameter is a handle to the active MDI *child* window, if any.// On Mac, the theWindow parameter is a pointer to the frontmost window, if any.////////////int QTFrame_AdjustMenus (WindowReference theWindow, MenuReference theMenu){#if TARGET_OS_MAC#pragma unused(theMenu)#endif WindowObject myWindowObject = NULL; MovieController myMC = NULL; MenuReference myMenu = NULL; #if TARGET_OS_WIN32 myMenu = theMenu;#endif if (theWindow != NULL) myWindowObject = QTFrame_GetWindowObjectFromWindow(theWindow); if (myWindowObject != NULL) myMC = (**myWindowObject).fController; ////////// // // configure the Edit menu // ////////// #if TARGET_OS_MAC myMenu = GetMenuHandle(kEditMenuResID);#endif if (myMC != NULL) { long myFlags; MCGetControllerInfo(myMC, &myFlags); QTFrame_SetMenuItemState(myMenu, IDM_EDITUNDO, myFlags & mcInfoUndoAvailable ? kEnableMenuItem : kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_EDITCUT, myFlags & mcInfoCutAvailable ? kEnableMenuItem : kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_EDITCOPY, myFlags & mcInfoCopyAvailable ? kEnableMenuItem : kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_EDITPASTE, myFlags & mcInfoPasteAvailable ? kEnableMenuItem : kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_EDITCLEAR, myFlags & mcInfoClearAvailable ? kEnableMenuItem : kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_EDITSELECTALL, myFlags & mcInfoEditingEnabled ? kEnableMenuItem : kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_EDITSELECTNONE, myFlags & mcInfoEditingEnabled ? kEnableMenuItem : kDisableMenuItem); } else { QTFrame_SetMenuItemState(myMenu, IDM_EDITUNDO, kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_EDITCUT, kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_EDITCOPY, kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_EDITPASTE, kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_EDITCLEAR, kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_EDITSELECTALL, kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_EDITSELECTNONE, kDisableMenuItem); } ////////// // // configure the File menu // ////////// #if TARGET_OS_MAC myMenu = GetMenuHandle(kFileMenuResID);#endif if (theWindow != NULL) { // there is a window open // handle the Close command QTFrame_SetMenuItemState(myMenu, IDM_FILECLOSE, kEnableMenuItem); // handle the Save As and Save commands if (myWindowObject != NULL) { QTFrame_SetMenuItemState(myMenu, IDM_FILESAVEAS, kEnableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_FILESAVE, (**myWindowObject).fIsDirty ? kEnableMenuItem : kDisableMenuItem); } else { QTFrame_SetMenuItemState(myMenu, IDM_FILESAVEAS, kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_FILESAVE, kDisableMenuItem); } } else { // there is no window open QTFrame_SetMenuItemState(myMenu, IDM_FILESAVE, kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_FILESAVEAS, kDisableMenuItem); QTFrame_SetMenuItemState(myMenu, IDM_FILECLOSE, kDisableMenuItem); } // adjust any application-specific menus QTApp_AdjustMenus(theWindow, theMenu); return(0);}/////////////////////////////////////////////////////////////////////////////////////////////////////////////// Movie-handling functions.//// Use these functions to create new movies, open existing movies, save movies, and so forth./////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// QTFrame_CreateNewMovie// Create a new movie in a window; returns true if successful.//// NOTE: There are several user interface issues that are blissfully ignored by this routine,// principally the preferred names and the on-screen locations of the new windows. ////////////Boolean QTFrame_CreateNewMovie (void){ Movie myMovie = NULL; FSSpec myFSSpec; StringPtr myName = QTUtils_ConvertCToPascalString(kNewMovieName); myMovie = NewMovie(newMovieActive); if (myMovie == NULL) return(false); // create a default FSSpec FSMakeFSSpec(0, 0L, myName, &myFSSpec); free(myName); return(OpenMovieInWindow(myMovie, &myFSSpec));}////////////// QTFrame_SaveAsMovieFile// Save the movie in the specified window under a new name.//// Human interface guidelines for "Save As..." dictate that, if the user selects a new file name// for the current movie, then that new file shall become the active one. This means that we need// to close the current movie file and open the new one.////////////OSErr QTFrame_SaveAsMovieFile (WindowReference theWindow){ WindowObject myWindowObject = NULL; Movie myMovie = NULL; FSSpec myFile; Boolean myIsSelected = false; Boolean myIsReplacing = false; StringPtr myPrompt = QTUtils_ConvertCToPascalString(kSavePrompt); StringPtr myFileName = QTUtils_ConvertCToPascalString(kSaveMovieFileName); OSErr myErr = paramErr; // get the window object associated with the specified window myWindowObject = QTFrame_GetWindowObjectFromWindow(theWindow); if (myWindowObject == NULL) goto bail; myMovie = (**myWindowObject).fMovie; if (myMovie == NULL) goto bail; QTFrame_PutFile(myPrompt, myFileName, &myFile, &myIsSelected, &myIsReplacing); if (myIsSelected) { Movie myNewMovie = NULL; MovieController myMC = NULL; long myFlags; short myRefNum = kInvalidFileRefNum; short myResID = movieInDataForkResID; ////////// // // we have a valid FSSpec for the new movie file; now we want to create a new movie file, // save the movie data into the new file, close the existing movie file, and then swap // the window object data // ////////// // delete any existing file of that name if (myIsReplacing) { myErr = DeleteMovieFile(&myFile); if (myErr != noErr) goto bail; } myFlags = createMovieFileDeleteCurFile | createMovieFileDontOpenFile | createMovieFileDontCreateMovie | createMovieFileDontCreateResFile; myErr = CreateMovieFile(&myFile, FOUR_CHAR_CODE('TVOD'), smSystemScript, myFlags, NULL, NULL); if (myErr != noErr) goto bail; myErr = OpenMovieFile(&myFile, &myRefNum, fsRdWrPerm); if (myErr != noErr) goto bail; // write existing movie's data into new movie file myErr = AddMovieResource(myMovie, myRefNum, &myResID, myFile.name); if (myErr != noErr) goto bail; // get the new movie from the file myErr = NewMovieFromFile(&myNewMovie, myRefNum, &myResID, NULL, newMovieActive, NULL); if (myErr != noErr) goto bail; // create a new movie controller myMC = CreateController(myNewMovie, theWindow, false); ////////// // // if we got to here, we've successfully created a new movie file, and NewMovieFromFile has // returned the new movie to us; so we need to close down the current movie and install the // new movie in its place // ////////// // close the existing movie file if ((**myWindowObject).fFileRefNum != kInvalidFileRefNum) CloseMovieFile((**myWindowObject).fFileRefNum); // dispose of the existing movie controller and movie resource DisposeMovieController((**myWindowObject).fController); DisposeMovie(myMovie); // keep track of the new info (**myWindowObject).fMovie = myNewMovie; (**myWindowObject).fController = myMC; (**myWindowObject).fFileFSSpec = myFile; (**myWindowObject).fFileResID = myResID; (**myWindowObject).fFileRefNum = myRefNum; (**myWindowObject).fIsDirty = false; // make sure the movie uses the window GWorld in all situations SetMovieGWorld(myNewMovie, (CGrafPtr)QTFrame_GetPortFromWindowReference((**myWindowObject).fWindow), NULL); // set the window title QTFrame_SetWindowTitleFromFSSpec(theWindow, &myFile, true); } else { myErr = userCanceledErr; }bail: free(myPrompt); free(myFileName); return(myErr);}////////////// QTFrame_UpdateMovieFile// Update the file (if any) attached to the movie.////////////Boolean QTFrame_UpdateMovieFile (WindowReference theWindow){ WindowObject myWindowObject = NULL; Movie myMovie = NULL; OSErr myErr = noErr; // get the window object associated with the specified window myWindowObject = QTFrame_GetWindowObjectFromWindow(theWindow); if (myWindowObject == NULL) return(false); myMovie = (**myWindowObject).fMovie; if (myMovie == NULL) return(false); // update the current volume setting QTUtils_UpdateMovieVolumeSetting(myMovie); if ((**myWindowObject).fFileRefNum == kInvalidFileRefNum) // brand new movie, so no file attached to it myErr = QTFrame_SaveAsMovieFile(theWindow); else // we have an existing file; just update the movie resource myErr = UpdateMovieResource(myMovie, (**myWindowObject).fFileRefNum, (**myWindowObject).fFileResID, NULL); (**myWindowObject).fIsDirty = false; return(myErr == noErr);}////////////// QTFrame_IdleMovieWindows// Do idle-time processing on all open movie windows.////////////void QTFrame_IdleMovieWindows (void){ WindowReference myWindow = NULL; MovieController myMC = NULL; myWindow = QTFrame_GetFrontMovieWindow(); while (myWindow != NULL) { myMC = QTFrame_GetMCFromWindow(myWindow); if (myMC != NULL) MCIdle(myMC); QTApp_Idle(myWindow); myWindow = QTFrame_GetNextMovieWindow(myWindow); }}////////////// QTFrame_CloseMovieWindows// Close all open movie windows.////////////void QTFrame_CloseMovieWindows (void){#if TARGET_OS_MAC WindowReference myWindow = NULL; WindowReference myNextWindow = NULL; myWindow = QTFrame_GetFrontMovieWindow(); while (myWindow != NULL) { myNextWindow = QTFrame_GetNextMovieWindow(myWindow); QTFrame_DestroyMovieWindow(myWindow); myWindow = myNextWindow; }#endif#if TARGET_OS_WIN32 SendMessage(ghWnd, WM_COMMAND, (WPARAM)IDM_WINDOWCLOSEALL, 0L);#endif}////////////// QTFrame_CreateWindowObject// Create a new window object associated with the specified window.////////////void QTFrame_CreateWindowObject (WindowReference theWindow){ WindowObject myWindowObject = NULL; if (theWindow == NULL) return; // allocate space for a window object record and fill in some of its fields myWindowObject = (WindowObject)NewHandleClear(sizeof(WindowObjectRecord)); if (myWindowObject != NULL) { (**myWindowObject).fWindow = theWindow; (**myWindowObject).fController = NULL; (**myWindowObject).fObjectType = kApplicationSignature; (**myWindowObject).fCanResizeWindow = true; (**myWindowObject).fInstance = NULL; (**myWindowObject).fIsDirty = false; (**myWindowObject).fAppData = NULL; } // associate myWindowObject (which may be NULL) with the window#if TARGET_OS_MAC SetWRefCon(theWindow, (long)myWindowObject);#endif#if TARGET_OS_WIN32 SetWindowLong(theWindow, GWL_USERDATA, (LPARAM)myWindowObject); // associate a GrafPort with this window CreatePortAssociation(theWindow, NULL, 0L);#endif // set the current port to the new window MacSetPort(QTFrame_GetPortFromWindowReference(theWindow));}////////////// QTFrame_CloseWindowObject// Close a window object and any associated data.////////////void QTFrame_CloseWindowObject (WindowObject theWindowObject){ if (theWindowObject == NULL) return; // close the movie file if ((**theWindowObject).fFileRefNum != kInvalidFileRefNum) { CloseMovieFile((**theWindowObject).fFileRefNum); (**theWindowObject).fFileRefNum = kInvalidFileRefNum; } // dispose movie controller and movie if ((**theWindowObject).fController != NULL) { MCSetActionFilterWithRefCon((**theWindowObject).fController, NULL, 0L); DisposeMovieController((**theWindowObject).fController); (**theWindowObject).fController = NULL; } if ((**theWindowObject).fMovie != NULL) { DisposeMovie((**theWindowObject).fMovie); (**theWindowObject).fMovie = NULL; } // close the graphics importer, if any if ((**theWindowObject).fGraphicsImporter != NULL) { CloseComponent((**theWindowObject).fGraphicsImporter); (**theWindowObject).fGraphicsImporter = NULL; } // do any application-specific window clean-up QTApp_RemoveWindowObject(theWindowObject); DisposeHandle((Handle)theWindowObject);}/////////////////////////////////////////////////////////////////////////////////////////////////////////////// Window-walking utilities.//// Use these functions to iterate through all windows or movie windows belonging to the application./////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// QTFrame_GetFrontAppWindow// Return a reference to the frontmost application window (whether or not it's a movie window).////////////WindowReference QTFrame_GetFrontAppWindow (void){#if TARGET_OS_MAC return(FrontWindow());#endif#if TARGET_OS_WIN32 return(GetWindow(ghWnd, GW_HWNDFIRST));#endif}////////////// QTFrame_GetNextAppWindow// Return a reference to the next application window (whether or not it's a movie window).////////////WindowReference QTFrame_GetNextAppWindow (WindowReference theWindow){#if TARGET_OS_MAC return(theWindow == NULL ? NULL : GetNextWindow(theWindow));#endif#if TARGET_OS_WIN32 return(GetWindow(theWindow, GW_HWNDNEXT));#endif}////////////// QTFrame_GetFrontMovieWindow// Return a reference to the frontmost movie window.////////////WindowReference QTFrame_GetFrontMovieWindow (void){ WindowReference myWindow;#if TARGET_OS_MAC myWindow = QTFrame_GetFrontAppWindow(); while ((myWindow != NULL) && (QTFrame_GetWindowObjectFromWindow(myWindow) == NULL)) myWindow = QTFrame_GetNextAppWindow(myWindow);#endif#if TARGET_OS_WIN32 myWindow = (HWND)SendMessage(ghWndMDIClient, WM_MDIGETACTIVE, 0, 0L);#endif return(myWindow);}////////////// QTFrame_GetNextMovieWindow// Return a reference to the next movie window.////////////WindowReference QTFrame_GetNextMovieWindow (WindowReference theWindow){ WindowReference myWindow;#if TARGET_OS_MAC myWindow = QTFrame_GetNextAppWindow(theWindow); while ((myWindow != NULL) && (QTFrame_GetWindowObjectFromWindow(myWindow) == NULL)) myWindow = QTFrame_GetNextAppWindow(myWindow);#endif#if TARGET_OS_WIN32 myWindow = GetWindow(theWindow, GW_HWNDNEXT);#endif return(myWindow);}/////////////////////////////////////////////////////////////////////////////////////////////////////////////// Data-retrieval utilities.//// Use the following functions to retrieve the window object, the application-specific data, or the movie// controller that is associated with a window./////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// QTFrame_GetWindowObjectFromFrontWindow// Get the window object (if any) associated with the front window.////////////WindowObject QTFrame_GetWindowObjectFromFrontWindow (void){ return(QTFrame_GetWindowObjectFromWindow(QTFrame_GetFrontMovieWindow()));}////////////// QTFrame_GetWindowObjectFromWindow// Get the window object (if any) associated with the specified window.////////////WindowObject QTFrame_GetWindowObjectFromWindow (WindowReference theWindow){ WindowObject myWindowObject = NULL; if (!QTFrame_IsAppWindow(theWindow)) return(NULL); #if TARGET_OS_MAC myWindowObject = (WindowObject)GetWRefCon(theWindow);#endif#if TARGET_OS_WIN32 myWindowObject = (WindowObject)GetWindowLong(theWindow, GWL_USERDATA);#endif // make sure this is a window object if (!QTFrame_IsWindowObjectOurs(myWindowObject)) return(NULL); return(myWindowObject);}////////////// QTFrame_GetMCFromFrontWindow// Get the movie controller (if any) associated with the front window.////////////MovieController QTFrame_GetMCFromFrontWindow (void){ return(QTFrame_GetMCFromWindow(QTFrame_GetFrontMovieWindow()));}////////////// QTFrame_GetMCFromWindow// Get the movie controller (if any) associated with the specified window.////////////MovieController QTFrame_GetMCFromWindow (WindowReference theWindow){ MovieController myMC = NULL; WindowObject myWindowObject = NULL; myWindowObject = QTFrame_GetWindowObjectFromWindow(theWindow); if (myWindowObject != NULL) myMC = (**myWindowObject).fController; return(myMC);}////////////// QTFrame_GetQTVRInstanceFromFrontWindow// Get the QTVRInstance (if any) associated with the front window.////////////QTVRInstance QTFrame_GetQTVRInstanceFromFrontWindow (void){ return(QTFrame_GetQTVRInstanceFromWindow(QTFrame_GetFrontMovieWindow()));}////////////// QTFrame_GetQTVRInstanceFromWindow// Get the QTVRInstance (if any) associated with the specified window.////////////QTVRInstance QTFrame_GetQTVRInstanceFromWindow (WindowReference theWindow){ QTVRInstance myInstance = NULL; WindowObject myWindowObject = NULL; myWindowObject = QTFrame_GetWindowObjectFromWindow(theWindow); if (myWindowObject != NULL) myInstance = (**myWindowObject).fInstance; return(myInstance);}////////////// QTFrame_GetAppDataFromFrontWindow// Get the application-specific data associated with the front window.////////////Handle QTFrame_GetAppDataFromFrontWindow (void){ return(QTFrame_GetAppDataFromWindow(QTFrame_GetFrontMovieWindow()));}////////////// QTFrame_GetAppDataFromWindow// Get the application-specific data associated with the specified window.////////////Handle QTFrame_GetAppDataFromWindow (WindowReference theWindow){ WindowObject myWindowObject = NULL; myWindowObject = QTFrame_GetWindowObjectFromWindow(theWindow); if (myWindowObject == NULL) return(NULL); return(QTFrame_GetAppDataFromWindowObject(myWindowObject));}////////////// QTFrame_GetAppDataFromWindowObject// Get the application-specific data associated with the specified window object.////////////Handle QTFrame_GetAppDataFromWindowObject (WindowObject theWindowObject){ // make sure this is a window object belonging to our application if (!QTFrame_IsWindowObjectOurs(theWindowObject)) return(NULL); return((**theWindowObject).fAppData);}////////////// QTFrame_IsWindowObjectOurs// Does the specified window object belong to our application?////////////Boolean QTFrame_IsWindowObjectOurs (WindowObject theWindowObject){ OSType myType = 0L; if ((theWindowObject == NULL) || (*theWindowObject == NULL)) return(false); myType = (**theWindowObject).fObjectType; return(myType == kApplicationSignature);}////////////// QTFrame_IsAppWindow// Does the specified window belong to our application?////////////Boolean QTFrame_IsAppWindow (WindowReference theWindow){ if (theWindow == NULL) return(false);#if TARGET_OS_MAC return(GetWindowKind(theWindow) >= kApplicationWindowKind);#endif#if TARGET_OS_WIN32 return(true);#endif}////////////// QTFrame_IsDocWindow// Is the specified window a document window (having a WindowObject refcon)?////////////Boolean QTFrame_IsDocWindow (WindowReference theWindow){ if (theWindow == NULL) return(false);#if TARGET_OS_MAC return(GetWindowKind(theWindow) >= kApplicationWindowKind);#endif#if TARGET_OS_WIN32 return(true);#endif}/////////////////////////////////////////////////////////////////////////////////////////////////////////////// Miscellaneous utilities.//// Use the following functions to play beeps, manipulate menus, and do other miscellaneous things./////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// QTFrame_Beep// Beep.////////////void QTFrame_Beep (void){#if TARGET_OS_MAC SysBeep(30);#endif#if TARGET_OS_WIN32 MessageBeep(MB_OK);#endif}////////////// QTFrame_SetMenuState// Set the enabled/disabled state of a menu.//// On Windows, the theMenuItem parameter must be the (0-based) index in the menu bar of the// desired pull-down menu.////////////void QTFrame_SetMenuState (MenuReference theMenu, UInt16 theMenuItem, short theState){#if TARGET_OS_MAC#pragma unused(theMenuItem) QTFrame_SetMenuItemState(theMenu, 0, theState); // menu item == 0 means the entire menu#endif#if TARGET_OS_WIN32 QTFrame_SetMenuItemState(theMenu, theMenuItem, theState | MF_BYPOSITION);#endif}////////////// QTFrame_SetMenuItemState// Set the enabled/disabled state of a menu item.//// When running under MacOS 8.5.1, EnableMenuItem and DisableMenuItem seem to do nasty things// to the keyboard equivalents associated with a menu; so we'll work around that problem here.////////////void QTFrame_SetMenuItemState (MenuReference theMenu, UInt16 theMenuItem, short theState){#if TARGET_OS_MAC UInt8 myModifiers; // get the existing menu item modifiers GetMenuItemModifiers(theMenu, MENU_ITEM(theMenuItem), &myModifiers); if (theState == kEnableMenuItem) EnableMenuItem(theMenu, MENU_ITEM(theMenuItem)); else DisableMenuItem(theMenu, MENU_ITEM(theMenuItem)); // restore the previous menu item modifiers SetMenuItemModifiers(theMenu, MENU_ITEM(theMenuItem), myModifiers);#endif#if TARGET_OS_WIN32 EnableMenuItem(theMenu, (UINT)theMenuItem, (UINT)theState);#endif}////////////// QTFrame_SetMenuItemLabel// Set the label (that is, the text) of a menu item.////////////void QTFrame_SetMenuItemLabel (MenuReference theMenu, UInt16 theMenuItem, char *theText){#if TARGET_OS_MAC Str255 myString; short mySIndex, myTIndex; // we need to remove the '&' character while converting to a Pascal string mySIndex = 1; for (myTIndex = 0; myTIndex < strlen(theText); myTIndex++) { if (theText[myTIndex] != '&') { myString[mySIndex] = theText[myTIndex]; mySIndex++; } } myString[0] = mySIndex - 1; SetMenuItemText(theMenu, MENU_ITEM(theMenuItem), myString);#endif#if TARGET_OS_WIN32 UINT myState; // make sure that we preserve the current menu state myState = GetMenuState(theMenu, (UINT)theMenuItem, MF_BYCOMMAND); ModifyMenu(theMenu, (UINT)theMenuItem, MF_BYCOMMAND | MF_STRING | myState, (UINT)theMenuItem, (LPSTR)theText);#endif}////////////// QTFrame_SetMenuItemCheck// Set the check mark state state of a menu item.////////////void QTFrame_SetMenuItemCheck (MenuReference theMenu, UInt16 theMenuItem, Boolean theState){#if TARGET_OS_MAC MacCheckMenuItem(theMenu, MENU_ITEM(theMenuItem), theState);#endif#if TARGET_OS_WIN32 CheckMenuItem(theMenu, (UINT)theMenuItem, theState ? MF_CHECKED : MF_UNCHECKED);#endif}////////////// QTFrame_GetPortFromWindowReference // Return the graphics port associated with a window reference.////////////GrafPtr QTFrame_GetPortFromWindowReference (WindowReference theWindow){#if TARGET_OS_MAC return((GrafPtr)GetWindowPort(theWindow));#endif#if TARGET_OS_WIN32 return(GetNativeWindowPort(theWindow));#endif}////////////// QTFrame_GetWindowReferenceFromPort// Return the window reference associated with a graphics port.////////////WindowReference QTFrame_GetWindowReferenceFromPort (GrafPtr thePort){#if TARGET_OS_MAC return((WindowReference)GetWindowFromPort((CGrafPtr)thePort));#endif#if TARGET_OS_WIN32 return((WindowReference)GetPortNativeWindow(thePort));#endif}////////////// QTFrame_GetWindowFromWindowReference// Return the Macintosh window associated with a window reference.////////////WindowPtr QTFrame_GetWindowFromWindowReference (WindowReference theWindow){#if TARGET_OS_MAC return((WindowPtr)theWindow);#endif#if TARGET_OS_WIN32 return((WindowPtr)GetNativeWindowPort(theWindow));#endif}///////////// QTFrame_GetWindowWidth// Return the width of the specified window.////////////short QTFrame_GetWindowWidth (WindowReference theWindow){#if TARGET_OS_MAC Rect myRect = {0, 0, 0, 0}; if (theWindow != NULL) GetWindowPortBounds(theWindow, &myRect);#endif#if TARGET_OS_WIN32 RECT myRect = {0L, 0L, 0L, 0L}; if (theWindow != NULL) GetWindowRect(theWindow, &myRect);#endif return((short)(myRect.right - myRect.left));}////////////// QTFrame_SetWindowTitleFromFSSpec// Set the title of the specified window, using the name contained in the specified FSSpec.////////////void QTFrame_SetWindowTitleFromFSSpec (WindowReference theWindow, FSSpecPtr theFSSpecPtr, Boolean theAddToRecentDocs){#if TARGET_OS_MAC#pragma unused(theAddToRecentDocs) SetWTitle(theWindow, theFSSpecPtr->name);#endif#if TARGET_OS_WIN32 char *myTempName; char myWindName[MAX_PATH]; // get the full pathname contained in the FSSpec (which is a Str255) myTempName = QTUtils_ConvertPascalToCString(theFSSpecPtr->name); // get the movie file name from the full pathname QTFrame_GetDisplayName(myTempName, myWindName); // set the window title SetWindowText(theWindow, myWindName); // add this document to the Documents list, if so instructed if (theAddToRecentDocs) SHAddToRecentDocs(SHARD_PATH, myTempName); free(myTempName);#endif}////////////// QTFrame_SizeWindowToMovie// Set the window size to exactly fit the movie and controller (if visible).////////////void QTFrame_SizeWindowToMovie (WindowObject theWindowObject){ Rect myMovieBounds; Movie myMovie = NULL; MovieController myMC = NULL; GraphicsImportComponent myImporter = NULL;#if TARGET_OS_WIN32 gWeAreSizingWindow = true;#endif if (theWindowObject == NULL) goto bail; myMovie = (**theWindowObject).fMovie; myMC = (**theWindowObject).fController; myImporter = (**theWindowObject).fGraphicsImporter; if (myImporter != NULL) { GraphicsImportGetBoundsRect(myImporter, &myMovieBounds); goto gotBounds; } if (myMovie == NULL) return; GetMovieBox(myMovie, &myMovieBounds); if (myMC != NULL) if (MCGetVisible(myMC)) MCGetControllerBoundsRect(myMC, &myMovieBounds); // make sure that the movie has a non-zero width; // a zero height is okay (for example, with a music movie with no controller bar) if (myMovieBounds.right - myMovieBounds.left == 0) { myMovieBounds.left = 0; myMovieBounds.right = QTFrame_GetWindowWidth((**theWindowObject).fWindow); }gotBounds: SizeWindow(QTFrame_GetWindowFromWindowReference((**theWindowObject).fWindow), myMovieBounds.right - myMovieBounds.left, myMovieBounds.bottom - myMovieBounds.top, true);bail: #if TARGET_OS_WIN32 gWeAreSizingWindow = false;#endif return;}/////////////////////////////////////////////////////////////////////////////////////////////////////////////// File-opening and -saving utilities.//// The functions are meant to provide replacements for StandardGetFilePreview and StandardPutFile, which// are not supported under Carbon. However, Navigation Services is not (yet, at any rate) supported under// Windows, so we still need to call through to the Standard File Package.//// The Navigation Services portion of this code is based selectively on the file NavigationServicesSupport.c// by Yan Arrouye and on the developer documentation "Programming With Navigation Services 1.1". The code that// determines which files can be opened by QuickTime is based on code by Sam Bushell in CarbonMovieEditor.c./////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// QTFrame_PutFile// Save a file under the specified name. Return Boolean values indicating whether the user selected a file// and whether the selected file is replacing an existing file.////////////OSErr QTFrame_PutFile (ConstStr255Param thePrompt, ConstStr255Param theFileName, FSSpecPtr theFSSpecPtr, Boolean *theIsSelected, Boolean *theIsReplacing){#if TARGET_OS_WIN32 StandardFileReply myReply;#endif#if TARGET_OS_MAC NavReplyRecord myReply; NavDialogOptions myDialogOptions; NavEventUPP myEventUPP = NewNavEventUPP(QTFrame_HandleNavEvent);#endif OSErr myErr = noErr; if ((theFSSpecPtr == NULL) || (theIsSelected == NULL) || (theIsReplacing == NULL)) return(paramErr); // deactivate any frontmost movie window ActivateController(QTFrame_GetFrontMovieWindow(), false); // assume we are not replacing an existing file *theIsReplacing = false; #if TARGET_OS_WIN32 StandardPutFile(thePrompt, theFileName, &myReply); *theFSSpecPtr = myReply.sfFile; *theIsSelected = myReply.sfGood; if (myReply.sfGood) *theIsReplacing = myReply.sfReplacing;#endif#if TARGET_OS_MAC // specify the options for the dialog box NavGetDefaultDialogOptions(&myDialogOptions); myDialogOptions.dialogOptionFlags += kNavNoTypePopup; myDialogOptions.dialogOptionFlags += kNavDontAutoTranslate; BlockMoveData(theFileName, myDialogOptions.savedFileName, theFileName[0] + 1); BlockMoveData(gAppName, myDialogOptions.clientName, gAppName[0] + 1); BlockMoveData(thePrompt, myDialogOptions.message, thePrompt[0] + 1); // prompt the user for a file myErr = NavPutFile(NULL, &myReply, &myDialogOptions, myEventUPP, MovieFileType, FOUR_CHAR_CODE('TVOD'), NULL); if ((myErr == noErr) && myReply.validRecord) { AEKeyword myKeyword; DescType myActualType; Size myActualSize = 0; // get the FSSpec for the selected file if (theFSSpecPtr != NULL) myErr = AEGetNthPtr(&(myReply.selection), 1, typeFSS, &myKeyword, &myActualType, theFSSpecPtr, sizeof(FSSpec), &myActualSize); NavDisposeReply(&myReply); } *theIsSelected = myReply.validRecord; if (myReply.validRecord) *theIsReplacing = myReply.replacing; DisposeNavEventUPP(myEventUPP);#endif return(myErr);} ////////////// QTFrame_GetOneFileWithPreview// Display the appropriate file-opening dialog box, with an optional QuickTime preview pane. If the user// selects a file, return information about it using the theFSSpecPtr parameter.//// Note that both StandardGetFilePreview and NavGetFile use the function specified by theFilterProc as a// file filter. This framework always passes NULL in the theFilterProc parameter. If you use this function// in your own code, keep in mind that on Windows the function specifier must be of type FileFilterUPP and // on Macintosh it must be of type NavObjectFilterUPP. (You can use the QTFrame_GetFileFilterUPP to create// a function specifier of the appropriate type.) Also keep in mind that Navigation Services expects a file // filter function to return true if a file is to be displayed, while the Standard File Package expects the// filter to return false if a file is to be displayed.////////////OSErr QTFrame_GetOneFileWithPreview (short theNumTypes, QTFrameTypeListPtr theTypeList, FSSpecPtr theFSSpecPtr, void *theFilterProc){#if TARGET_OS_WIN32 StandardFileReply myReply;#endif#if TARGET_OS_MAC NavReplyRecord myReply; NavDialogOptions myDialogOptions; NavTypeListHandle myOpenList = NULL; NavEventUPP myEventUPP = NewNavEventUPP(QTFrame_HandleNavEvent);#endif OSErr myErr = noErr; if (theFSSpecPtr == NULL) return(paramErr); // deactivate any frontmost movie window ActivateController(QTFrame_GetFrontMovieWindow(), false);#if TARGET_OS_WIN32 // prompt the user for a file StandardGetFilePreview((FileFilterUPP)theFilterProc, theNumTypes, (ConstSFTypeListPtr)theTypeList, &myReply); if (!myReply.sfGood) return(userCanceledErr); // make an FSSpec record myErr = FSMakeFSSpec(myReply.sfFile.vRefNum, myReply.sfFile.parID, myReply.sfFile.name, theFSSpecPtr);#endif#if TARGET_OS_MAC // specify the options for the dialog box NavGetDefaultDialogOptions(&myDialogOptions); myDialogOptions.dialogOptionFlags -= kNavNoTypePopup; myDialogOptions.dialogOptionFlags -= kNavAllowMultipleFiles; BlockMoveData(gAppName, myDialogOptions.clientName, gAppName[0] + 1); // create a handle to an 'open' resource myOpenList = (NavTypeListHandle)QTFrame_CreateOpenHandle(kApplicationSignature, theNumTypes, theTypeList); if (myOpenList != NULL) HLock((Handle)myOpenList); // prompt the user for a file myErr = NavGetFile(NULL, &myReply, &myDialogOptions, myEventUPP, NULL, (NavObjectFilterUPP)theFilterProc, myOpenList, NULL); if ((myErr == noErr) && myReply.validRecord) { AEKeyword myKeyword; DescType myActualType; Size myActualSize = 0; // get the FSSpec for the selected file if (theFSSpecPtr != NULL) myErr = AEGetNthPtr(&(myReply.selection), 1, typeFSS, &myKeyword, &myActualType, theFSSpecPtr, sizeof(FSSpec), &myActualSize); NavDisposeReply(&myReply); } if (myOpenList != NULL) { HUnlock((Handle)myOpenList); DisposeHandle((Handle)myOpenList); } DisposeNavEventUPP(myEventUPP);#endif return(myErr);}////////////// QTFrame_HandleNavEvent// A callback procedure that handles events while a Navigation Service dialog box is displayed.////////////PASCAL_RTN void QTFrame_HandleNavEvent (NavEventCallbackMessage theCallBackSelector, NavCBRecPtr theCallBackParms, void *theCallBackUD){#pragma unused(theCallBackUD) WindowReference myWindow = NULL; if (theCallBackSelector == kNavCBEvent) { switch (theCallBackParms->eventData.eventDataParms.event->what) { case updateEvt:#if TARGET_OS_MAC QTFrame_HandleEvent(theCallBackParms->eventData.eventDataParms.event);#endif break; case nullEvent: QTFrame_IdleMovieWindows(); break; } }}////////////// QTFrame_CreateOpenHandle// Return a handle to a dynamically-created 'open' resource.////////////Handle QTFrame_CreateOpenHandle (OSType theApplicationSignature, short theNumTypes, QTFrameTypeListPtr theTypeList){ Handle myHandle = NULL; if (theTypeList == NULL) return(myHandle); if (theNumTypes > 0) { myHandle = NewHandle(sizeof(NavTypeList) + (theNumTypes * sizeof(OSType))); if (myHandle != NULL) { NavTypeListHandle myOpenResHandle = (NavTypeListHandle)myHandle; (*myOpenResHandle)->componentSignature = theApplicationSignature; (*myOpenResHandle)->osTypeCount = theNumTypes; BlockMoveData(theTypeList, (*myOpenResHandle)->osType, theNumTypes * sizeof(OSType)); } } return(myHandle);}////////////// QTFrame_GetFileFilterUPP// Return a UPP for the specified file-selection filter function.//// The caller is responsible for disposing of the UPP returned by this function (by calling DisposeRoutineDescriptor).////////////QTFrameFileFilterUPP QTFrame_GetFileFilterUPP (ProcPtr theFileFilterProc){#if TARGET_OS_MAC return(NewNavObjectFilterUPP((NavObjectFilterProcPtr)theFileFilterProc));#endif#if TARGET_OS_WIN32 return(NewFileFilterProc(theFileFilterProc));#endif}////////////// QTFrame_FilterFiles// Filter files for a file-opening dialog box.//// The default behavior here is to accept all files that can be opened by QuickTime, whether directly// or using a movie importer or a graphics importer.////////////#if TARGET_OS_MACPASCAL_RTN Boolean QTFrame_FilterFiles (AEDesc *theItem, void *theInfo, void *theCallBackUD, NavFilterModes theFilterMode){#pragma unused(theCallBackUD, theFilterMode) NavFileOrFolderInfo *myInfo = (NavFileOrFolderInfo *)theInfo; if (gValidFileTypes == NULL) QTFrame_BuildFileTypeList(); if (theItem->descriptorType == typeFSS) { if (!myInfo->isFolder) { OSType myType = myInfo->fileAndFolder.fileInfo.finderInfo.fdType; short myCount; short myIndex; // see whether the file type is in the list of file types that our application can open myCount = GetPtrSize((Ptr)gValidFileTypes) / sizeof(OSType); for (myIndex = 0; myIndex < myCount; myIndex++) if (myType == gValidFileTypes[myIndex]) return(true); // if we got to here, it's a file we cannot open return(false); } } // if we got to here, it's a folder or non-HFS object return(true);}#endif#if TARGET_OS_WIN32PASCAL_RTN Boolean QTFrame_FilterFiles (CInfoPBPtr thePBPtr){#pragma unused(thePBPtr) return(false);}#endif////////////// QTFrame_BuildFileTypeList// Build a list of file types that QuickTime can open.////////////OSErr QTFrame_BuildFileTypeList (void){ long myIndex = 0; OSErr myErr = noErr; // if we've already built the list, just return if (gValidFileTypes != NULL) return(myErr); // allocate a block of memory to hold a preset number of file types; we'll resize this block // while building the list if we need more room; we always resize it after building the list, // to truncate it to the exact size required gValidFileTypes = (OSType *)NewPtrClear(sizeof(OSType) * kDefaultFileTypeCount); if (gValidFileTypes == NULL) return(memFullErr); // we can open any files of type kQTFileTypeMovie gValidFileTypes[myIndex++] = kQTFileTypeMovie; // we can open any files for which QuickTime supplies a movie importer component QTFrame_AddComponentFileTypes(MovieImportType, &myIndex); // we can open any files for which QuickTime supplies a graphics importer component QTFrame_AddComponentFileTypes(GraphicsImporterComponentType, &myIndex); // resize the pointer to hold the exact number of valid file types SetPtrSize((Ptr)gValidFileTypes, myIndex * sizeof(OSType)); myErr = MemError(); return(myErr);}////////////// QTFrame_AddComponentFileTypes// Add all subtypes of the specified component type to the global list of file types.////////////static void QTFrame_AddComponentFileTypes (OSType theComponentType, long *theNextIndex){ ComponentDescription myFindCompDesc = {0, 0, 0, 0, 0}; ComponentDescription myInfoCompDesc = {0, 0, 0, 0, 0}; Component myComponent = NULL; myFindCompDesc.componentType = theComponentType; myFindCompDesc.componentFlags = 0; myFindCompDesc.componentFlagsMask = movieImportSubTypeIsFileExtension; myComponent = FindNextComponent(myComponent, &myFindCompDesc); while (myComponent != NULL) { GetComponentInfo(myComponent, &myInfoCompDesc, NULL, NULL, NULL); gValidFileTypes[*theNextIndex] = myInfoCompDesc.componentSubType; *theNextIndex += 1; // resize the block of file types, if we are about to reach the limit if (*theNextIndex == GetPtrSize((Ptr)gValidFileTypes) / (long)sizeof(OSType)) { SetPtrSize((Ptr)gValidFileTypes, GetPtrSize((Ptr)gValidFileTypes) + (kDefaultFileTypeCount * sizeof(OSType))); if (MemError() != noErr) return; } myComponent = FindNextComponent(myComponent, &myFindCompDesc); }}#if TARGET_OS_WIN32////////////// QTFrame_ConvertMacToWinRect// Convert a Macintosh Rect structure into a Windows RECT structure.////////////void QTFrame_ConvertMacToWinRect (Rect *theMacRect, RECT *theWinRect){ theWinRect->top = (long)theMacRect->top; theWinRect->left = (long)theMacRect->left; theWinRect->bottom = (long)theMacRect->bottom; theWinRect->right = (long)theMacRect->right;}////////////// QTFrame_ConvertWinToMacRect// Convert a Windows RECT structure into a Macintosh Rect structure.////////////void QTFrame_ConvertWinToMacRect (RECT *theWinRect, Rect *theMacRect){ theMacRect->top = (short)theWinRect->top; theMacRect->left = (short)theWinRect->left; theMacRect->bottom = (short)theWinRect->bottom; theMacRect->right = (short)theWinRect->right;}#endif</pre>
<!--googleoff: index -->
</td>
</tr>
</table>
<!-- END WIDE COLUMN -->
<!-- END MAIN CONTENT -->
<table width="680" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><div style="width: 100%; height: 1px; background-color: #919699; margin-top: 5px; margin-bottom: 15px"></div></td>
</tr>
<tr>
<td align="center"><br/>
<table border="0" cellpadding="0" cellspacing="0" class="graybox">
<tr>
<th>Did this document help you?</th>
</tr>
<tr>
<td>
<div style="margin-bottom: 8px"><a href="http://developer.apple.com/feedback/?v=1&url=/samplecode/Play_Movie_with_Controller/listing22.html%3Fid%3DDTS10001041-1.0&media=dvd" target=_new>Yes</a>: Tell us what works for you.</div>
<div style="margin-bottom: 8px"><a href="http://developer.apple.com/feedback/?v=2&url=/samplecode/Play_Movie_with_Controller/listing22.html%3Fid%3DDTS10001041-1.0&media=dvd" target=_new>It’s good, but:</a> Report typos, inaccuracies, and so forth.</div>
<div><a href="http://developer.apple.com/feedback/?v=3&url=/samplecode/Play_Movie_with_Controller/listing22.html%3Fid%3DDTS10001041-1.0&media=dvd" target=_new>It wasn’t helpful</a>: Tell us what would have helped.</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- START BOTTOM APPLE NAVIGATION -->
<!--#include virtual="/includes/footer"-->
<!-- END BOTTOM APPLE NAVIGATION -->
<!-- START CENTER CLOSE -->
</center>
<!-- END CENTER CLOSE -->
</body>
</html>