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