What is F-IN-BOX DLL Edition?

F-IN-BOX is a window control to enhance Macromedia / Adobe Flash Player ActiveX features. It does not use its own engine to display movies but provide a wrapper around official swflash.ocx/flash.ocx code instead. Thus it is possible to avoid certain Macromedia / Adobe Flash Player ActiveX limitations.

All Macromedia / Adobe Flash Player ActiveX versions are supported.

Both x86 and x64 are supported.

Want to see F-IN-BOX in action?

Just enter a correct e-mail to get a demo version.

If you don't receive a letter please write us: support (at) f-in-box.com, or via support form.



Load flash movies directly from any source (no temporary files!). Protect your flash movies.

It is known fact that the Flash Player ActiveX is able to load movies at certain URLs only. You have to save the movie to a temporary location from your application's resource before you can load it. You'll have to generate a corresponding link that you can pass to the Flash Player ActiveX and then delete the movie after. You'll have to admit that this is extremely inconvenient. Apart from being inconvenient there is a chance you'll fail when you try to create a temporary file if you don't have the appropriate permission or don't have access to a temporary folder. It is definitely not an appropriate approach when security is an issue since your movie can be easily intercepted. There is a solution! F-IN-BOX uses a different approach of swflash.ocx/flash.ocx code loading. It is able to load your movies directly to the Macromedia / Adobe Flash Player ActiveX thereby avoiding the temporary file step. The advantages are pretty obvious. And you can also protect your movies from unauthorized access using your favourite software protection application.

Using the control you can load any flash movie from memory directly. Just use the FPCM_LOADMOVIEFROMMEMORY and FPCM_PUTMOVIEFROMMEMORY messages. No temporary files! Load any movie on-the-fly from any supported source. For example, you can put one or more flash movies in the resource section of your application and then load it from the exe! 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);
								


Create flash-enabled applications which are ready to work even when the Macromedia / Adobe Flash Player ActiveX is not installed!

One of the biggest problem using the Flash Player ActiveX is the mandatory component registration. The common approach is to save swflash.ocx/flash.ocx code to temporary files and then register them. The disadvantages are the same as above mentioned - insufficient permissions to save and register an swflash.ocx/flash.ocx. Now you can forget about these problems! F-IN-BOX is able to use swflash.ocx/flash.ocx from any source. For example, you can put an swflash.ocx/flash.ocx code inside of your application's resources and instruct F-IN-BOX to use it. It is important to note that F-IN-BOX does not use temporary files and swflash.ocx/flash.ocx registration but loads and uses the code directly. No more user management rights problems - no more temporary files and no more component registrations. It is up to you to decide what swflash.ocx/flash.ocx to use - by default already registered component is used.

Traditionally, there are many obstacles or annoyances that one will encounter when using Macromedia / Adobe Flash Player ActiveX in an application.

The Application...

  1. needs swflash.ocx/flash.ocx installed in the system before it will work.
  2. has to work flawlessly with the already installed version of the Macromedia / Adobe Flash Player ActiveX.
  3. has no easy way to prevent flash movies from being abused.

F-IN-BOX to the rescue. It solves these problems and more!

By default, the component will use the swflash.ocx/flash.ocx that's already installed on the system. The component can alternatively use any swflash.ocx/flash.ocx that you would like to provide it with using any supported source. An example of this how you can embed the flash.ocx into the resource section of your application's exe file and then load it at runtime. Using this method, your application will work even if the Macromedia / Adobe Flash Player ActiveX doesn't exist on the target system. Just use RegisterFlashWindowClassEx function! With F-IN-BOX, hassling around with Macromedia / Adobe Flash Player ActiveX installation issues are a thing the past! It's so 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);
								


Transparency is fully supported!

Using F-IN-BOX you are able to create applications based on transparent flash movies. You can create applications with translucency non-rectangle windows. Use Flash to make applications with modern user interface. See the code:

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);
								


Ability to play Flash Video (FLV) from memory

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

To play Flash Video from memory you should create flash movie that loads Flash Video from "private" URL (http://FLV/FlashVideo.flv). Flash Movie uses the following code to load Flash Video (put this in 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 content of FLV. Use function FPC_AddOnLoadExternalResourceHandler to handle the external resources and provide 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;  
} 
								

Enable/disable flash sounds

Using the library you can turn on/off all sounds in all loaded flash movies that belong to the same HFPC.

  • Use function FPC_EnableSound to enable/disable the sounds.
  • Use function FPC_IsSoundEnabled to get current status of sounds enabling.

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

Adjust sound volume

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


Get a snap image of the current flash movie frame

You can get a bitmap image from the current frame of a flash movie. It means you are able create applications that can coverts Flash movies to a series of bitmaps, JPEGs and others. Also you can build generated images to make 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);   
}
								


Flash External API

F-IN-BOX supports External API. You can call functions of a movie and a movie is able to get data from an application synchronously (instead of fscommand).

Call an ActionScript function from an application

Register your function 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"; 
}
					

Use function FPCCallFunction or FPCCallFunctionBSTR:

WCHAR szRequest[1024] = { 0 };   
  
lstrcatW(szRequest, L(""));  
lstrcatW(szRequest, L(""));  
lstrcatW(szRequest, L("Some text for F-IN-BOX"));  
lstrcatW(szRequest, L("");  
  
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(""));  
lstrcat(szRequest, _T(""));  
lstrcat(szRequest, _T("Some text for F-IN-BOX"));  
lstrcat(szRequest, _T("");  
  
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:

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

Handle notification FPCN_FLASHCALL:

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("Current time is: ") +   
now.Format() +   
_T("\r\nThis info is returned from the handler"));   
  
                    return 1;   
            }   
        }   
...  
  
}
								


Use a flash movie as a dynamic texture in DirectX / OpenGL applications

You can get semitransparent bitmap images from a flash movie. It means you are able create a dynamic texture for your DirectX / OpenGL application.

Here 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;   
}
								


Write code which is compatible with any version of Macromedia / Adobe Flash Player ActiveX

One of the problem with Macromedia / Adobe Flash Player ActiveX programming is that you have to control what version of Macromedia / Adobe Flash Player ActiveX you are using. For example, the property "Stacking" exists only in Macromedia / Adobe Flash Player ActiveX 5 but doesn't exist in later revisions. F-IN-BOX automatically detects what Macromedia / Adobe Flash Player ActiveX version is being used and prevents failure if access to non existant properties/methods is attempted. Applications using F-IN-BOX are not only compatible with any version of Macromedia / Adobe Flash Player ActiveX, but are also "smart" about how Macromedia / Adobe Flash Player ActiveX control is used. This makes your application more robust which can result in fewer technical support issues.