I am having difficulties trapping the WM_CLOSE so that I can display a prompt.
All flash events are trapped inside method FPCListener which is what I want.
but as soon as I
Code: Select all
RegisterClassEx(&wcx);
then all events are trapped inside method windowProc which would be ok but the flash does not load in the window(big problem).
Hope there is a solution.
Code: Select all
FlashCommunication::Load()
{
string m_Path = "https://jflash.dev.java.net/testdata/testpp.swf";
HFPC m_hFPC = FPC_LoadRegisteredOCX();
// Define the Window Class
WNDCLASSEX wcx;
wcx.cbSize = sizeof(wcx);
wcx.style = CS_HREDRAW | CS_VREDRAW;
wcx.lpfnWndProc = windowProc;
wcx.cbClsExtra = 0;
wcx.cbWndExtra = 0;
wcx.hInstance = AfxGetInstanceHandle();
wcx.hIcon = LoadIcon(wcx.hInstance,MAKEINTRESOURCE(IDI_ICON1));
wcx.hIconSm = LoadIcon(wcx.hInstance,MAKEINTRESOURCE(IDI_ICON1));
wcx.hCursor = NULL;
wcx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); //NULL
wcx.lpszMenuName = NULL;
wcx.lpszClassName = FPC_GetClassName(m_hFPC);
// Register Window Class
m_Atom = RegisterClassEx(&wcx);
HWND hwndFPC3 = CreateWindowEx(NULL, (LPCTSTR)FPC_GetClassAtom(m_hFPC), NULL, WS_POPUP | WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 800, 600, NULL, NULL, NULL, NULL);
FPC_LoadMovie(hwndFPC3, 0, m_Path.c_str() );
ShowWindow(hwndFPC3, SW_SHOWNORMAL);
FPCSetEventListener(hwndFPC3, FPCListener, 0);
}
void WINAPI FlashCommunication::FPCListener(HWND pHwnd, LPARAM lParam, NMHDR* pNMHDR)
{
FlashCommunication* pObj = theApp.GetFlashCommunicationInstance(pHwnd);
}
LRESULT CALLBACK FlashCommunication::windowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (uMsg==WM_CLOSE)
{
int result = MessageBox(hwnd,
"Are you sure you want to close this application?",
"Close...",
MB_YESNO | MB_ICONQUESTION);
if(result==IDYES)
{
theApp.RemoveFlashCommunicationInstance(hwnd);
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
else
return 0;
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}