What is F-IN-BOX DLL Edition?

F-IN-BOX is a window control that enhances the functionality of Macromedia / Adobe Flash Player ActiveX. Instead of using its own rendering engine, it wraps the official swflash.ocx / flash.ocx, allowing developers to overcome many limitations of the standard ActiveX control.

The control supports all versions of Macromedia / Adobe Flash Player ActiveX and works on both x86 and x64 architectures. It can be used with any programming language that supports DLLs, such as C++, VB6, and Java.

F-IN-BOX allows you to load Flash movies directly from any source without creating temporary files, making it easy to protect your Flash content. There's no need for Flash installation on the target system. You can build translucent and non-rectangular Flash-based UIs, load and play FLV videos from files, URLs, or memory, and fully control sound — including enabling, disabling, and adjusting volume.

The library also supports capturing Flash frames as images, interacting with Flash movies via the External API, and creating dynamic textures for OpenGL or DirectX. F-IN-BOX automatically handles version compatibility, ensuring your code works reliably with any version of Flash Player ActiveX.

Want to see F-IN-BOX in action?

Enter a valid email address to receive the demo version.

If you don't receive the email, please contact us.

Key Features

It is a well-known fact that Flash Player ActiveX can load movies only from specific URLs. Typically, you need to extract a movie from your application's resources and save it to a temporary location before it can be loaded. Then, you must generate a URL pointing to that file and pass it to Flash Player ActiveX—only to delete the file afterward.

This approach is not only inconvenient, but also error-prone. For instance, if your application lacks sufficient permissions or access to the temporary directory, it may fail to create the file. Moreover, when security is a concern, this method is unsuitable since the movie can be easily intercepted.

There is a better solution. F-IN-BOX uses a different approach to load swflash.ocx / flash.ocx content. It allows you to load movies directly into Macromedia / Adobe Flash Player ActiveX without creating any temporary files. The advantages are clear—you can even protect your movies from unauthorized access using your favorite software protection tool.

With F-IN-BOX, you can load any Flash movie directly from memory. Simply use the FPCM_LOADMOVIEFROMMEMORY and FPCM_PUTMOVIEFROMMEMORY messages. No temporary files are needed! Load any movie on the fly from any supported source. For example, you can embed one or more Flash movies into your application's resources and load them directly from the executable. That's the portability and power of F-IN-BOX!

Here's an example of how to load a Flash movie from a resource:

HFPC hFPC = FPC_LoadRegisteredOCX();
 
if (NULL == hFPC)
    return;
 
HWND hwndFlashPlayerControl = 
   FPC_CreateWindow(hFPC, 
                    0, 
                    NULL, 
                    WS_CHILD | WS_VISIBLE, 
                    nLeft, 
                    nTop, 
                    nWidth, 
                    nHeight, 
                    hWnd, 
                    NULL, 
                    NULL, 
                    NULL)
 
HMODULE hModule = GetModuleHandle(NULL);
HRSRC hResInfo = FindResource(hModule, _T("EmbeddedMovie"), _T("FLASH"));
HGLOBAL hResData = LoadResource(hModule, hResInfo);
LPVOID lpMovieData = LockResource(hResData);
DWORD dwMovieSize = SizeofResource(hModule, hResInfo);
 
SFPCPutMovieFromMemory sFPCPutMovieFromMemory;
 
sFPCPutMovieFromMemory.lpData = lpMovieData;
sFPCPutMovieFromMemory.dwSize = dwMovieSize;
 
::SendMessage(hwndFlashPlayerControl, 
              FPCM_PUTMOVIEFROMMEMORY, 
              0, 
              (LPARAM)&sFPCPutMovieFromMemory);

One of the biggest problems when using Flash Player ActiveX is the requirement to register the component. The typical approach is to extract swflash.ocx/flash.ocx to temporary files and then register them. This method comes with all the previously mentioned disadvantages — such as insufficient permissions to save or register the OCX file.

Now you can forget about those problems! F-IN-BOX can use swflash.ocx/flash.ocx from any source. For example, you can embed the code inside your application's resources and instruct F-IN-BOX to use it. Importantly, F-IN-BOX does not use temporary files or require component registration — it loads and uses the code directly. No more permission issues, no more temporary files, and no more registration headaches.

It's entirely up to you which version of swflash.ocx/flash.ocx to use — by default, the already registered component will be used.

Traditionally, developers encounter several obstacles when working with Macromedia / Adobe Flash Player ActiveX:

  • The application needs swflash.ocx/flash.ocx installed on the system to function.
  • It must be fully compatible with the already installed version of Flash Player ActiveX.
  • It offers no easy way to protect Flash movies from misuse.

F-IN-BOX to the rescue! It addresses all of these issues — and more.

By default, the component uses the version of swflash.ocx/flash.ocx already installed on the system. Alternatively, you can provide your own version from any supported source. For instance, you can embed flash.ocx into the resource section of your application's executable and load it at runtime. This way, your application will work even if Flash Player ActiveX is not installed on the target system.

Just use the RegisterFlashWindowClassEx function! With F-IN-BOX, dealing with Flash Player ActiveX installation issues is a thing of the past — and it's incredibly easy to do.

Here's an example of how to load swflash.ocx/flash.ocx code from a resource:

HMODULE hModule = GetModuleHandle(NULL);  
HRSRC hResInfo = FindResource(hModule, _T("FLASH_OCX_CODE"), _T("BIN"));  
HGLOBAL hResData = LoadResource(hModule, hResInfo);  
LPVOID lpFlashOCXCode = LockResource(hResData);  
DWORD dwFlashOCXCodeSize = SizeofResource(hModule, hResInfo);  
   
HFPC hFPC = FPC_LoadOCXFromMemory(lpFlashOCXCodeData, dwFlashOCXCodeSize);  
   
if (NULL == hFPC)  
{  
    // Error  
}

Here's an example of how to load swflash.ocx/flash.ocx code from a file:

HANDLE hFile = CreateFile(_T("flash.ocx"),   
                          GENERIC_READ,   
                          FILE_SHARE_READ,   
                          NULL,   
                          OPEN_EXISTING,   
                          FILE_ATTRIBUTE_NORMAL,   
                          NULL);  
   
DWORD dwFlashOCXCodeSize = GetFileSize(hFile, NULL);  
   
HANDLE hFileMapping = CreateFileMapping(hFile,   
                                        NULL,   
                                        PAGE_READONLY,   
                                        0,   
                                        dwFlashOCXCodeSize,   
                                        NULL);  
   
LPVOID lpFlashOCXCodeData = MapViewOfFile(hFileMapping, FILE_MAP_READ, 0, 0, 0);  
   
HFPC hFPC = FPC_LoadOCXFromMemory(lpFlashOCXCodeData, dwFlashOCXCodeSize);  
   
if (NULL == hFPC)  
{  
    // Error  
}          
   
UnmapViewOfFile(lpFlashOCXCodeData);  
CloseHandle(hFileMapping);  
CloseHandle(hFile);

Using F-IN-BOX, you can create applications based on transparent Flash movies, including translucent and non-rectangular windows. Use Flash to design modern user interfaces. See the code below:

HFPC hFPC = FPC_LoadRegisteredOCX();
   
RECT rc = { 0, 0, 640, 480 };
   
HWND hwndFlashPlayerControl =   
   FPC_CreateWindow(hFPC,   
                    WS_EX_LAYERED,   
                    NULL,   
                    WS_POPUP | WS_VISIBLE,   
                    nLeft,   
                    nTop,   
                    nWidth,   
                    nHeight,   
                    hWnd,   
                    NULL,   
                    NULL,   
                    NULL)  
   
ShowWindow(hwndFlashPlayerControl, SW_SHOW);  
   
UpdateWindow(hwndFlashPlayerControl);

Using F-IN-BOX, you can play Flash Video (FLV) from external files, URLs, or directly from memory. When F-IN-BOX loads Flash Video, no temporary files are created — everything runs directly from memory. You can even encrypt your video and embed it into your application's resources — F-IN-BOX loads the FLV without ever saving or extracting it to disk.

To play Flash Video from memory, you should create a Flash movie that loads the video from a "private" URL (e.g., http://FLV/FlashVideo.flv). The Flash movie should use the following code to load the video (place this under a button in your SWF Flash movie):

var netConn:NetConnection = new NetConnection();
netConn.connect(null);
 
var netStream:NetStream = new NetStream(netConn);
my_video.attachVideo(netStream);
netStream.setBufferTime(0);
netStream.play("http://FLV/FlashVideo.flv");

When Flash tries to load Flash Video from http://FLV/FlashVideo.flv, F-IN-BOX provides the content of the FLV. Use the function FPC_AddOnLoadExternalResourceHandler to handle external resources and supply them to Flash. See the code:

HFPC hFPC = FPC_LoadRegisteredOCX();  
   
FPC_AddOnLoadExternalResourceHandler(hFPC, &GlobalOnLoadExternalResourceHandler, 0);  
   
HRESULT WINAPI StaticGlobalOnLoadExternalResourceHandler(  
    LPCTSTR lpszURL,   
    IStream** ppStream,   
    HFPC hFPC,   
    LPARAM lParam)  
{  
    HRESULT hr = E_FAIL;  
   
    if (0 == lstrcmpi(lpszURL, _T("http://FLV/FlashVideo.flv")))  
    {  
        // Save flash video to the stream from the resource  
        HMODULE hModule = GetModuleHandle(NULL);  
        HRSRC hResInfo = FindResource(hModule, _T("EMBEDDED_FLV"), _T("FLV"));  
        HGLOBAL hResData = LoadResource(hModule, hResInfo);  
        LPCVOID lpData = LockResource(hResData);  
        DWORD dwSize = SizeofResource(hModule, hResInfo);  
   
        ULONG nWritten;  
        (*ppStream)->Write(lpData, dwSize, &nWritten);  
   
        hr = S_OK;  
    }  
   
    return hr;  
}

Using the library, you can turn on or off all sounds in all loaded Flash movies that belong to the same HFPC.

Use the function FPC_EnableSound to enable or disable sound.

Use the function FPC_IsSoundEnabled to get the current sound status. See the code:

void Mute()
{
  FPC_EnableSound(hFPC, FALSE);
}

Using the library, you can adjust the sound volume of all loaded Flash movies that belong to the same HFPC. To set the volume, call FPC_SetSoundVolume.

You can capture a bitmap image from the current frame of a Flash movie. This allows you to create applications that convert Flash movies into a series of bitmaps, JPEGs, and other formats. You can also use the generated images to build an AVI video, for example.

#include <atlimage.h>
 
SFPCGetFrameBitmap FPCGetFrameBitmap = { 0 };
 
::SendMessage(g_hwndFlashPlayerControl,
             FPCM_GET_FRAME_BITMAP,
             0,
             (LPARAM)&FPCGetFrameBitmap);
 
HBITMAP hBitmap = FPCGetFrameBitmap.hBitmap;
 
if (NULL != hBitmap)
{
    CImage Image;
    Image.Attach(hBitmap);
    Image.Save(_T("Frame.bmp"));
    Image.Detach();
    DeleteObject(hBitmap);
}

F-IN-BOX supports the External API, allowing you to call functions within a Flash movie and enabling the movie to retrieve data from the application synchronously (instead of using fscommand).

You can:

  • Call an ActionScript function from your application
  • Call an application function from your Flash script

Call an ActionScript Function from Your Application

First, register your function in ActionScript using ExternalInterface.addCallback:

import flash.external.*;
 
ExternalInterface.addCallback("CallMeFromApplication", this, InternalFunction);
 
function InternalFunction(str: String): String {
    TextArea1.text = str;
    return "The function was called successfully";
}

Then call the function from your application using FPCCallFunction or FPCCallFunctionBSTR:

WCHAR szRequest[1024] = { 0 };   
   
lstrcatW(szRequest, L"<invoke name=\"CallMeFromApplication\" returntype=\"xml\">");
lstrcatW(szRequest, L"<arguments><string>");
lstrcatW(szRequest, L"Some text for F-IN-BOX");
lstrcatW(szRequest, L"</string></arguments></invoke>");
   
BSTR bstrRequest = SysAllocString(szRequest);  
   
BSTR bstrResponse;   
   
if (S_OK ==   
    FPCCallFunctionBSTR(m_hwndFlashPlayerControl,   
                        bstrRequest,   
                        &bstrResponse))   
{   
    USES_CONVERSION;   
   
    CString str = OLE2T(bstrResponse);   
    AfxMessageBox(CString(_T("The function returned: ")) + str);   
   
    SysFreeString(bstrResponse);   
}   
   
SysFreeString(bstrRequest);
TCHAR szResponse[1024] = { 0 };   
   
DWORD dwLength = sizeof(szResponse) / sizeof(szResponse[0]) - 1;   
   
TCHAR szRequest[1024] = { 0 };   
   
lstrcat(szRequest, _T("<invoke name=\"CallMeFromApplication\" returntype=\"xml\">"));
lstrcat(szRequest, _T("<arguments><string>"));  
lstrcat(szRequest, _T("Some text for F-IN-BOX"));  
lstrcat(szRequest, _T("</string></arguments></invoke>");  
   
FPCCallFunction(m_hwndFlashPlayerControl,   
                szRequest,   
                szResponse,   
                &dwLength);   
   
AfxMessageBox(CString(_T("The function returned: ")) + szResponse);

Call an Application Function from a Flash Script

Use flash.external.ExternalInterface.call in your ActionScript code:

on (click) {
  _root.TextArea1.text = flash.external.ExternalInterface.call("SomeFunction");
}

Then handle the call in your application using the FPCN_FLASHCALL notification:

LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam)   
{   
    if (WM_NOTIFY == message)   
    {   
        LPNMHDR lpNMHDR = (LPNMHDR)lParam;   
   
        if (m_hwndFlashPlayerControl == lpNMHDR->hwndFrom)   
            switch (lpNMHDR->code)   
            {   
                case FPCN_FLASHCALL:   
                {   
                    SFPCFlashCallInfoStruct* pInfo = (SFPCFlashCallInfoStruct*)lpNMHDR;   
   
                    CString str;   
                    str += _T("The request is: '");   
                    str += pInfo->request;   
                    str += _T("'");   
   
                    AfxMessageBox(str);   
   
                    COleDateTime now = COleDateTime::GetCurrentTime();   
                    FPCSetReturnValue(m_hwndFlashPlayerControl,   
_T("<string>Current time is: ") +   
now.Format() +   
_T("
This info is returned from the handler</string>"));   
   
                    return 1;   
            }   
        }   
...  
   
}

You can obtain semitransparent bitmap images from a Flash movie, enabling you to create dynamic textures for your DirectX or OpenGL application.

Here is the texture based on the movie:

Texture based on the Flash movie
#define DEF_WIDTH (128)   
#define DEF_HEIGHT (128)   
   
HWND g_hwndFlashPlayerControl;   
...  
   
HFPC hFPC = FPC_LoadRegisteredOCX();   
   
// Create FlashPlayerControl as a hidden child control   
// in transparent mode (see style FPCS_TRANSPARENT)   
g_hwndFlashPlayerControl =   
    CreateWindow((LPCTSTR)FPC_GetClassAtom(hFPC),   
                 NULL,   
                 WS_CHILD | FPCS_TRANSPARENT,   
                 0,   
                 0,   
                 DEF_WIDTH,   
                 DEF_HEIGHT,   
                 hWnd,   
                 NULL,   
                 NULL,   
                 NULL);   
   
// Load movie from resource   
FPCPutMovieFromResource(g_hwndFlashPlayerControl, NULL, _T("SWF1"), _T("SWF"));   
// Play   
FPC_Play(g_hwndFlashPlayerControl);   
...  
   
// Creates texture from current frame   
LPDIRECT3DTEXTURE8 CreateTextureFromFlash()   
{   
    LPDIRECT3DTEXTURE8 pTexture = NULL;   
   
    D3DXCreateTexture(g_PDIRECT3DDEVICE8,   
                      DEF_WIDTH,   
                      DEF_HEIGHT,   
                      1,   
                      0,   
                      D3DFMT_A8R8G8B8,   
                      D3DPOOL_MANAGED,   
                      &pTexture);   
                         
    if (NULL == pTexture)   
        return pTexture;   
   
    D3DSURFACE_DESC d3dsd;   
    pTexture->GetLevelDesc(0, &d3dsd);   
   
    MoveWindow(g_hwndFlashPlayerControl,   
               0,   
               0,   
               d3dsd.Width,   
               d3dsd.Height,   
               TRUE);   
   
    SIZE size = { d3dsd.Width, d3dsd.Height };   
   
    D3DLOCKED_RECT rcLockedRect = { 0 };   
    RECT rc = { 0, 0, size.cx, size.cy };   
   
    pTexture->LockRect(0, &rcLockedRect, &rc, D3DLOCK_DISCARD);   
   
    SFPCGetFrameBitmap FPCGetFrameBitmap = { 0 };   
   
    ::SendMessage(g_hwndFlashPlayerControl,   
                  FPCM_GET_FRAME_BITMAP,   
                  0,   
                  (LPARAM)&FPCGetFrameBitmap);   
   
    HBITMAP hBitmap = FPCGetFrameBitmap.hBitmap;   
   
    BITMAP bmp_info;   
    GetObject(hBitmap, sizeof(bmp_info), &bmp_info);   
   
    BYTE* pTextureBits = (BYTE*)rcLockedRect.pBits;   
   
    DWORD* pBitmapBits = (DWORD*)bmp_info.bmBits;   
   
    BYTE* pLineTextureBits = pTextureBits;   
   
    for (int j = 0; j < size.cy; j++)   
    {   
        DWORD* pPixels = (DWORD*)pLineTextureBits;   
   
        for (int i = 0; i < size.cx; i++)   
        {   
            *pPixels = *pBitmapBits;   
   
            pPixels++;   
            pBitmapBits++;   
        }   
   
        pLineTextureBits += rcLockedRect.Pitch;   
    }   
   
    DeleteObject(hBitmap);   
   
    pTexture->UnlockRect(0);   
   
    return pTexture;   
}

One of the problems with Macromedia / Adobe Flash Player ActiveX programming is the need to manage which version of the control is being used. For example, the property "Stacking" exists only in Flash Player ActiveX 5 and is not available in later versions. F-IN-BOX automatically detects the version of Flash Player ActiveX in use and prevents failures when accessing non-existent properties or methods.

Applications built with F-IN-BOX are not only compatible with any version of Flash Player ActiveX, but also handle the control intelligently. This makes your application more robust and can lead to fewer technical support issues.