unable to get FSCommand to work

DLL Edition of the F-IN-BOX
firegod
Posts: 2
Joined: Wed Jan 16, 2008 5:17 am

unable to get FSCommand to work

Postby firegod » Wed Jan 16, 2008 5:23 am

Hi All,

My code looks this below, and my problem is when I call FSCommand from my .swf movie it doesn't work properly. The listener gets called and the switch detects the FPCN_FSCOMMAND correctly but the lparam is zero causing an exception due to pInfo being null.

I'm using the latest f in box demo, on Windows XP SP2 all compiled using VS2005.


Any ideas what I'm doing wrong?


Code: Select all

#include <atlbase.h>
#include <atlwin.h>

#include "f_in_box.h"
#pragma comment(lib, "f_in_box.lib")


LRESULT CALLBACK MyWindowProc(HWND,UINT,WPARAM,LPARAM);
void WINAPI Listener(HWND hwndFlashPlayerControl, LPARAM lParam, NMHDR* pNMHDR);

HWND hWnd;

/******************************************************************************************
* FUNCTION   : WinMain
* ACTION     :
* PARAMETERS :
*******************************************************************************************/
int WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPrevInst,PSTR sxCommand,int iShow)
{
  WNDCLASSEX myWindow;
  HWND hwndFPC1;

  HFPC hFPC = FPC_LoadRegisteredOCX();

 
  myWindow.cbClsExtra    = 0;
  myWindow.cbSize        = sizeof(myWindow);
  myWindow.cbWndExtra    = 0;
  myWindow.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  myWindow.hCursor       = LoadCursor(NULL,IDC_ARROW);
  myWindow.hIcon         = LoadIcon(NULL,IDI_APPLICATION);
  myWindow.hIconSm       = LoadIcon(NULL,IDI_APPLICATION);
  myWindow.hInstance     = hInst;
  myWindow.lpfnWndProc   = MyWindowProc;
  myWindow.lpszClassName = L"finbox";
  myWindow.lpszMenuName  = NULL;
  myWindow.style         = CS_HREDRAW | CS_VREDRAW;
  RegisterClassEx(&myWindow);
 
  CoInitialize(0);
  AtlAxWinInit();
  hWnd = CreateWindow(L"finbox",L"finbox Test",WS_OVERLAPPEDWINDOW,0,0,640,480,NULL,NULL,hInst,NULL);
  if(hWnd)
  {
    ShowWindow(hWnd, 1);
    UpdateWindow(hWnd);
   
    hwndFPC1 = FPC_CreateWindow(hFPC,0,NULL,WS_CHILD | WS_VISIBLE,0,0,600,480,hWnd,NULL,NULL,NULL);
   
    FPCSetEventListener(hwndFPC1,&Listener,0);
   
    SFPCPutMovie SFPCPutMovie;
    SFPCPutMovie.lpszBuffer = L"V:\\games\\test2\\test2\\test.swf";
    SendMessage(hwndFPC1, FPCM_PUT_MOVIE, 0, (LPARAM)&SFPCPutMovie);


    MSG msg;
    while(GetMessage(&msg,NULL,0,0))
    {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
    }
  }

  AtlAxWinTerm();
  CoUninitialize();

  return 0 ;
}

/******************************************************************************************
* FUNCTION   : MyWindowProc
* ACTION     :
* PARAMETERS :
*******************************************************************************************/
LRESULT CALLBACK MyWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
  switch(msg)
  {
  case WM_CREATE:
    {
      LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;
      return 0;
    }
  case WM_SIZE:
    {
      return 0;
    }
  case WM_DESTROY:
    PostQuitMessage(0);
    return 0;
  }
  return DefWindowProc(hWnd, msg, wParam, lParam);
}

/******************************************************************************************
* FUNCTION   : Listener
* ACTION     :
* PARAMETERS :
*******************************************************************************************/
void WINAPI Listener(HWND hwndFlashPlayerControl, LPARAM lParam, NMHDR* pNMHDR)
{
  switch (pNMHDR->code)
  {
    case FPCN_FSCOMMAND:
    {
      SFPCFSCommandInfoStruct* pInfo = (SFPCFSCommandInfoStruct*)lParam;

      MessageBox(hWnd, pInfo->command, _T("FSCommand(): command"), MB_OK | MB_ICONINFORMATION);
      MessageBox(hWnd, pInfo->args, _T("FSCommand(): args"), MB_OK | MB_ICONINFORMATION);

      break;
    }
  }
}

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Re: unable to get FSCommand to work

Postby Softanics » Wed Jan 16, 2008 7:36 am

Thank you for your question.

firegod wrote:/******************************************************************************************
* FUNCTION : Listener
* ACTION :
* PARAMETERS :
*******************************************************************************************/
void WINAPI Listener(HWND hwndFlashPlayerControl, LPARAM lParam, NMHDR* pNMHDR)
{
switch (pNMHDR->code)
{
case FPCN_FSCOMMAND:
{
SFPCFSCommandInfoStruct* pInfo = (SFPCFSCommandInfoStruct*)lParam;

MessageBox(hWnd, pInfo->command, _T("FSCommand(): command"), MB_OK | MB_ICONINFORMATION);
MessageBox(hWnd, pInfo->args, _T("FSCommand(): args"), MB_OK | MB_ICONINFORMATION);

break;
}
}
}


lParam of the Listener is a lParam that is passed to the FPCSetListener, use it to provide additional information to the Listener (for example, you can cast passed lParam to an object pointer). To retrieve SFPCFSCommandInfoStruct* use the following code:

Code: Select all

SFPCFSCommandInfoStruct* pInfo = (SFPCFSCommandInfoStruct*)pNMHDR; // don't cast lParam, cast pNMHDR
Best regards, Artem A. Razin,
F-IN-BOX support
Ask your question here: http://www.f-in-box.com/support.html

firegod
Posts: 2
Joined: Wed Jan 16, 2008 5:17 am

Re: unable to get FSCommand to work

Postby firegod » Wed Jan 16, 2008 9:50 am

Thanks Artem,

A super speedy reply and it fixed my problem. Thanks and if I can get
communications going the other way into my flash movie I will be buying your product.


Return to “DLL Edition”

Who is online

Users browsing this forum: No registered users and 14 guests

cron