Getting Started

F-IN-BOX, DLL Edition is a wrapper around the official Macromedia / Adobe Flash Player ActiveX (swflash.ocx / flash.ocx).
It does not implement its own rendering engine but instead extends the features of the official ActiveX control, removing several of its limitations.


Creating an F-IN-BOX window

  1. Create an HFPC handle.

    These functions load the control code and register an F-IN-BOX window class.

  2. Obtain the class atom using FPC_GetClassAtom. Pass this atom to CreateWindow / CreateWindowEx or use FPC_CreateWindow directly to create a window.

  3. After all windows associated with a given HFPC are destroyed, call FPC_UnloadCode to unload the Flash code.

Supported window types

  • Child window, Window Mode
    Standard child window rendering.

  • Child window, Transparent Mode
    Allows capturing frames with an alpha channel.

  • Popup window, Transparent Mode
    Enables creating semitransparent, non-rectangular windows based on Flash content (useful for custom GUI).

Example

HFPC hFPC;
HWND hwndFPC1, hwndFPC2, hwndFPC3;
 
hFPC = FPC_LoadRegisteredOCX();
 
if (NULL == hFPC)
   return; // Failed to load Flash ActiveX
 
hwndFPC1 = 
   FPC_CreateWindow(hFPC, 
                    0, 
                    NULL, 
                    WS_CHILD | WS_VISIBLE, 
                    nLeft, 
                    nTop, 
                    nWidth, 
                    nHeight, 
                    hWnd, 
                    NULL, 
                    NULL, 
                    NULL);
 
hwndFPC2 = 
   CreateWindow((LPCTSTR)FPC_GetClassAtom(hFPC), 
                NULL, 
                WS_CHILD | WS_VISIBLE | FPCS_TRANSPARENT, 
                rc.left, 
                rc.top, 
                rc.right - rc.left, 
                rc.bottom - rc.top, 
                hWnd, 
                NULL, 
                NULL, 
                NULL);
 
hwndFPC3 = 
   CreateWindowEx(WS_EX_LAYERED, 
                  (LPCTSTR)FPC_GetClassAtom(hFPC), 
                  NULL, 
                  WS_POPUP | WS_VISIBLE, 
                  rc.left, 
                  rc.top, 
                  rc.right - rc.left, 
                  rc.bottom - rc.top, 
                  NULL, 
                  NULL, 
                  NULL, 
                  NULL);
 
if (NULL != hFPC)
{
   FPC_UnloadCode(hFPC);
   hFPC = NULL;
}

Loading a movie

Movies can be loaded from files, URLs, resources, or memory.

These return an IStream that you should write content into and release when complete.

Example (resource)

// Load movie from resource
FPCPutMovieFromResource(hwndFlashPlayerControl, NULL, _T("MOVIE"), _T("SWF"));

Example (streaming with thread marshalling)

IStream* pStream;
FPCPutMovieUsingStream(hwndFlashPlayerControl, &pStream);
 
// Marshal the stream to another thread
IStream* pStreamForMarshalling;
CoMarshalInterThreadInterfaceInStream(IID_IStream, pStream, &pStreamForMarshalling);
 
pStream->Release();
pStream = NULL;
 
DWORD dwThreadId;
HANDLE hThread = 
   CreateThread(NULL, 
                0, 
                &FlashContentProviderThread, 
                (LPVOID)pStreamForMarshalling, 
                0, 
                &dwThreadId);
CloseHandle(hThread);
 
DWORD WINAPI FlashContentProviderThread(LPVOID lpParameter)
{
   CoInitialize(NULL);
 
   IStream* pStreamForMarshalling = (IStream*)lpParameter;
   IStream* pStream;
 
   CoUnmarshalInterface(pStreamForMarshalling, IID_IStream, (void**)&pStream);
 
   while (...)
      if (S_OK != pStream->Write(...))
         break;
 
   pStreamForMarshalling->Release();
   pStream->Release();
 
   CoUninitialize();
}

Notes

Since Adobe Flash reached End of Life (EOL) in December 2020, most modern systems no longer have Flash Player ActiveX installed by default. This makes the ability of F-IN-BOX to load the Flash ActiveX control code from memory (using FPC_LoadOCXCodeFromMemory) especially important, as it allows applications to remain functional without requiring system-wide installation or registration of Flash.