Exemple #1
0
boolean isplayerevent (void) {
	
	/*
	7.0b4 PBS: called from the main event loop.
	QuickTime needs to catch some events.
	Return true if the event is consumed by QuickTime
	and should be ignored by the event loop.
	*/
	
	boolean fl = false;
	
	if (currentmovie == nil) /*if no current movie, return right away*/
	
		return (fl);
	
	if (currentcontroller == nil) /*if no controller, return right away*/
		
		return (fl);
	
	if (MCIsPlayerEvent (currentcontroller, &shellevent))
		
		fl = true; /*the event was consumed by QuickTime*/
	
	MCIdle (currentcontroller);
	
	MoviesTask (nil, 0);
		
	return (fl);
	} /*isplayerevent*/
static void IdleMovie()
{
    if (mMovieController)
    {
        EventRecord	myEvent;
        
        myEvent.what = nullEvent;
        myEvent.message = 0;
        myEvent.modifiers = 0;
        myEvent.when = EventTimeToTicks(GetCurrentEventTime());
        
        MCIsPlayerEvent(mMovieController, &myEvent);
    }
}
LRESULT CALLBACK QTFrame_MovieWndProc (HWND theWnd, UINT theMessage, UINT wParam, LONG lParam)
{
	WPARAM				myWidth, myHeight;
	MovieController		myMC = NULL;
	Movie				myMovie = NULL;
	WindowObject		myWindowObject = NULL;
	MSG					myMsg = {0};
	EventRecord			myMacEvent;
	Boolean				myIsHandled = false;

	// get the window object, movie, and movie controller for this window
	myWindowObject = QTFrame_GetWindowObjectFromWindow(theWnd);
	if (myWindowObject != NULL) {
		myMC = (**myWindowObject).fController;
		myMovie = (**myWindowObject).fMovie;
	}

	// give the movie controller this message first
	if ((!gShuttingDown) && (theMessage != WM_COMMAND)) {
		LONG			myPoints = GetMessagePos();

		myMsg.hwnd = theWnd;
		myMsg.message = theMessage;
		myMsg.wParam = wParam;
		myMsg.lParam = lParam;
		myMsg.time = GetMessageTime();
		myMsg.pt.x = LOWORD(myPoints);
		myMsg.pt.y = HIWORD(myPoints);

		// translate a Windows event to a Mac event
		WinEventToMacEvent(&myMsg, &myMacEvent);

		// let the application-specific code have a chance to intercept the event
		myIsHandled = QTApp_HandleEvent(&myMacEvent);
		
		// pass the Mac event to the movie controller, but only if the movie window isn't minimized
		if (!myIsHandled)
			if (myMC != NULL)
				if (!IsIconic(theWnd))
					myIsHandled = MCIsPlayerEvent(myMC, (EventRecord *)&myMacEvent);
	}

	switch (theMessage) {
		case WM_CREATE: {
				LONG		myStyles;
				
				// create a new window object associated with the new window
				QTFrame_CreateWindowObject(theWnd);
			
				// disable the maximize button
				myStyles = GetWindowLong(theWnd, GWL_STYLE);
				myStyles &= ~WS_MAXIMIZEBOX;
				SetWindowLong(theWnd, GWL_STYLE, myStyles);
			}
			break;

		case WM_WINDOWPOSCHANGING:
			// don't show the window until we have created a movie and
			// can therefore properly size the window to contain the movie
			if (gWeAreCreatingWindow) {
				WINDOWPOS	*lpWindowPos = (WINDOWPOS*)lParam;
				
				lpWindowPos->flags &= ~SWP_SHOWWINDOW;
			}
			break;

		case WM_WINDOWPOSCHANGED:
			// if a movie window has become minimized, stop the movie
			if (IsIconic(theWnd))
				StopMovie(myMovie);
			break;

		case WM_SIZE:
			// resize the movie and controller to fit the window
			myWidth = LOWORD(lParam);
			myHeight = HIWORD(lParam);
			
			// we do NOT want to resize the movie controller if the window is minimized,
			// if there is no movie controller, or if we are in the middle of resizing the window
			if (!gWeAreSizingWindow && (myMC != NULL) && (wParam != SIZE_MINIMIZED)) {
				Rect		myRect;
				
				myRect.top = 0;
				myRect.left = 0;
				myRect.right = myWidth;
				myRect.bottom = myHeight;
				
				MCSetControllerBoundsRect(myMC, &myRect);
			}
			break;

		case WM_MOUSEMOVE:
			// for QuickTime movies (but NOT for QuickTime VR movies), set the cursor to the arrow cursor
			if (myWindowObject != NULL)
				if (!(**myWindowObject).fIsQTVRMovie)
					SetCursor(LoadCursor(NULL, IDC_ARROW));
			break;

		case WM_PUMPMOVIE:
			// we receive this message only to task the movie
			break;

		case WM_LBUTTONDOWN:
			// do any application-specific mouse-button handling, but only if the message hasn't already been handled
			if (!myIsHandled)
				QTApp_HandleContentClick(theWnd, &myMacEvent);
			break;

		case WM_CHAR:
			// do any application-specific key press handling
			QTApp_HandleKeyPress((char)wParam);
			break;

		case WM_PAINT: {
			// do any application-specific drawing in the window
				PAINTSTRUCT		myPaintStruct;

				BeginPaint(theWnd, &myPaintStruct);

				// if the window contains an image, draw it using GraphicsImportDraw
				if (myWindowObject != NULL)
					if ((**myWindowObject).fGraphicsImporter != NULL)
						GraphicsImportDraw((**myWindowObject).fGraphicsImporter);
			
				QTApp_Draw(theWnd);
				
				EndPaint(theWnd, &myPaintStruct);
			}
			break;

		case WM_MDIACTIVATE:
			// activate or deactivate the movie controller in the specified window
			QTFrame_ActivateController(theWnd, (HWND)theWnd == (HWND)lParam);
			break;

		case WM_COMMAND: {

			switch (LOWORD(wParam)) {
							
				case IDM_FILESAVE:
				case IDM_FILESAVEAS:
					QTFrame_HandleFileMenuItem(theWnd, LOWORD(wParam));
					break;

				case IDM_EDITUNDO:
				case IDM_EDITCUT:
				case IDM_EDITCOPY:
				case IDM_EDITPASTE:
				case IDM_EDITCLEAR:
				case IDM_EDITSELECTALL:
				case IDM_EDITSELECTNONE:
					QTFrame_HandleEditMenuItem(theWnd, LOWORD(wParam));
					break;
					
				default:
					// do any application-specific menu handling
					QTApp_HandleMenu((UInt16)LOWORD(wParam));
					break;
			}
			
			break;
		}	// case WM_COMMAND

		case WM_GETMINMAXINFO:
			QTFrame_CalcWindowMinMaxInfo(theWnd, (LPMINMAXINFO)lParam);
			return(0);

		case WM_CLOSE:
			// prepare to close the window, making sure that any changed data is saved or explicitly discarded;
			// we can still cancel the window closing here
			if (myWindowObject != NULL) {
			
				// if the window's data is "dirty", give the user a chance to save it
				if ((**myWindowObject).fIsDirty) {
					int			myItem;
					char		myText[256];
					UINT		myAction;
		
					// get the title of the window
					GetWindowText(theWnd, myText, sizeof(myText));
		
					// specify the action
					myAction = gShuttingDown ? IDS_SAVEONQUIT : IDS_SAVEONCLOSE;
		
					// display the "Save changes" dialog box
					myItem = QTFrame_ShowCautionAlert(theWnd, myAction, MB_ICONEXCLAMATION, MB_YESNOCANCEL, gAppName, myText);
					switch (myItem) {
						case kSaveChanges:
							// save the data in the window
							QTFrame_UpdateMovieFile(theWnd);
							break;
							
						case kCancelClose:
							// do not close the window and do not quit the application
							gShuttingDown = false;
							return(0);
						
						case kDontSaveChanges:
							// discard any unsaved changes (that is, don't do anything)
							break;
							
						default:
							// unexpected item selected; just return
							return(0);
					}
				}
			} // if (myWindowObject != NULL)
			
			// if we got to this point, it's okay to close and destroy the window
			SendMessage(ghWndMDIClient, WM_MDIDESTROY, (WPARAM)theWnd, 0L);
			break;

		case WM_DESTROY:
			// when we get this message,
			// the window has been removed from the screen and its associated data must be destroyed
			if (myWindowObject != NULL)
				QTFrame_CloseWindowObject(myWindowObject);
		
			SetWindowLong(theWnd, GWL_USERDATA, 0);

			// destroy the port association
			DestroyPortAssociation((CGrafPtr)GetHWNDPort(theWnd));
			
			break;
	}

	return(DefMDIChildProc(theWnd, theMessage, wParam, lParam));
}