Page 1 of 1

How to handle alt-tab when playing full screen over TGE

Posted: Sat Jan 29, 2011 12:47 am
by kauaiBlake
Hi there,

First let me say thank you for a good working product. Using your DLL for my client company, I have been able to bring their game to the windows 7 platform.

The game plays flash movies/games as mini games or cutscrenes over a window owned by the main game built using Torque Game Engine. I had to use a few non-obvious function calls to get the movies to play correctly over the TGE window in full screen.

I am having one issue that I am having trouble resolving. I am creating a full screen flash window using WS_POPUP style (code below..), and I get it to play fine, but I do not handle alt-tab properly yet and thats my question. How to handle alt-tab and then alt tab back. I believe its the same issue for click on the second screen causing the flash movie to lose focus.

I would like that the flash application paused and then resumed, but I do not see an easy way to do this with the current API. I tried to just stop and then play again. I can stop the movie at the first alt tab, but it does not want to play when I tab back, though I know my code is executing via file prints, and that includes a FPC_Play call. Let me show the relevant code....

First the meat of the window initialize call...

Code: Select all

m_hwndFlashPlayerControl = CreateWindow((LPCTSTR)FPC_GetClassAtom(m_hFPC),
                   //NULL,     WS_POPUP | WS_VISIBLE,
                   NULL,     WS_POPUP,
                   rc.left, rc.top,  rc.right - rc.left, rc.bottom - rc.top,
                   hWnd,  NULL,  NULL,  NULL);

   if ( FPC_GetVersion(FPC_GetHFPC(m_hwndFlashPlayerControl)) >= DEF_MINIMAL_FLASH_VERSION_THAT_ALLOWS_FULLSCREEN )   
   // Allowfullscreen is available   
   {   
      FPC_EnableFullScreen(m_hwndFlashPlayerControl, TRUE);   
   } 

   // Associate my "this" pointer
   SetWindowLong (m_hwndFlashPlayerControl, GWL_USERDATA, (LONG) this);
   // save old window proc
   m_OldWndProc = (WNDPROC)GetWindowLong(m_hwndFlashPlayerControl, GWL_WNDPROC);
   // set new window proc
   SetWindowLong(m_hwndFlashPlayerControl, GWL_WNDPROC, (long) windowProc);
   // if window set focus
   if (IsWindow(m_hwndFlashPlayerControl))
       mhOldFocusWnd = ::SetFocus(m_hwndFlashPlayerControl);
   // set event listener and reset window position to get it to play
   if (m_hwndFlashPlayerControl != NULL)
   {
      FPCSetEventListener(m_hwndFlashPlayerControl, FPCListener, (LPARAM)(this));
      ::SetWindowPos(m_hwndFlashPlayerControl,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);      
   }


Now the heart of the play movie in window code

Code: Select all


 if (m_hwndFlashPlayerControl)
   {
      // set the scale mode
      SFPCPutScaleMode info;
      info.ScaleMode = 2;
      ::SendMessage(m_hwndFlashPlayerControl, FPCM_PUT_SCALEMODE, 0, (LPARAM)&info);

      // get the character string for the movie to play
      strncpy(m_url_buffer,url,1023);
      m_url_buffer[1023]=0;
      backslash(m_url_buffer);

      // make message structure and send message to load movie
      SFPCPutMovie FPCPutMovie;
      FPCPutMovie.lpszBuffer = m_url_buffer;
      ::SendMessage(m_hwndFlashPlayerControl, FPCM_PUT_MOVIE, 0, (LPARAM)&FPCPutMovie);

      // send message to play it
      FPC_Play(m_hwndFlashPlayerControl);

      // make it visible
      ::ShowWindow(m_hwndFlashPlayerControl,SW_SHOW);

      // this needs to be here for FS view to be seen
      ::BringWindowToTop(m_hwndFlashPlayerControl);
   }


Finally the code I have been using to try and handle to losing and gaining of focus in the windowProc message handling function for the WM_ACTIVATEAPP message type.

Code: Select all

      case WM_ACTIVATEAPP:
         if (wParam == 0)
         {
            // minimize flash window
            FPC_Stop(pFlashWrapper->m_hwndFlashPlayerControl);
         }
         else
         {
            // restore flash window
            //SFPCPlay FPCPlayMovie;
            //FPCPlayMovie.hr = 1;
            //::SendMessage(pFlashWrapper->m_hwndFlashPlayerControl, FPCM_PLAY, 0, (LPARAM)&FPCPlayMovie);

            // make message structure and send message to load movie
            //SFPCPutMovie FPCPutMovie;
            //FPCPutMovie.lpszBuffer = pFlashWrapper->m_url_buffer;
            //::SendMessage(pFlashWrapper->m_hwndFlashPlayerControl, FPCM_PUT_MOVIE, 0, (LPARAM)&FPCPutMovie);

            // this needs to be here for FS view to be seen
            //::BringWindowToTop(pFlashWrapper->m_hwndFlashPlayerControl);

            // send message to play it
            FPC_Play(pFlashWrapper->m_hwndFlashPlayerControl);

            // make it visible
            //::ShowWindow(pFlashWrapper->m_hwndFlashPlayerControl,SW_RESTORE);

         }

         break;



I have tried lots of combinations of calls, as you might tell from commented out code. Any suggestions on how to handle this? I am more a game engine coder than a windows messaging type coder , so any help is greatly appreciated. :)

Posted: Sat Jan 29, 2011 2:54 am
by kauaiBlake
Also, does anyone know how to limit the mouse to the single screen? In a multimonitor setup, a click on the second screen will end the full screen flash window on the first screen.

Posted: Mon Jan 31, 2011 2:26 pm
by Softanics
Thank you for your question.

So the idea is to stop the movie with focus lost and resumes when it does receive focus, right?

The first question. Is the movie can be stopped by FPC_Stop() ?

Thank you.

Posted: Tue Feb 01, 2011 12:07 am
by kauaiBlake
Thank you for your help in getting back to me.

Yes I can stop the movie with a stop FPC_STOP. I just cant get it to restart with FPC_PLAY. I know I only execute the stop, and then play one time each becuase I was tracing execution with file printing.

Happy to answer any questions on this to try and make it work. Thanks again.