AtlAxAttachControl - An outgoing call cannot be made since the application is dispatching an input-syncronous call.
-
I'm at the end of my rope here... I've been bashing my head on my keyboard for the last week trying to figure out this issue. I'm trying to display a flash control on a DirectDraw surface and my call to AtlAxAttachControl fails - preventing the flash player from appearing within the control. Here's a stripped down version of my code:
#pragma once
#include <string>
#include <windows.h>
#include <exdisp.h>
#include <mshtmlc.h>#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>using std::string;
#import "PROGID:ShockwaveFlash.ShockwaveFlash" no_namespace raw_interfaces_only
typedef HRESULT (WINAPI *LPAtlAxWinInit) ();
typedef HRESULT (WINAPI *LPAtlAxGetControl)(HWND hwnd, IUnknown** unk);class FlashViewer
{
public:
FlashViewer();
~FlashViewer();bool Init(int Width, int Height); void OpenFlash(const char\* filename); void DrawToSurface(LPDIRECTDRAWSURFACE7 lpdds);
private:
int mViewerWidth;
int mViewerHeight;HWND mViewerWnd; IShockwaveFlash\* mFlashCtrl;
};
FlashViewer::FlashViewer()
{
mViewerWidth = 0;
mViewerHeight = 0;mViewerWnd = 0; mFlashCtrl = NULL;
}
FlashViewer::~FlashViewer()
{
DestroyWindow(this->mViewerWnd);
if (this->mFlashCtrl != NULL)
{
this->mFlashCtrl->Release();
this->mFlashCtrl = NULL;
}
}bool FlashViewer::Init(int width, int height)
{
LPAtlAxWinInit AtlAxWinInit3 = (LPAtlAxWinInit)GetProcAddress(LoadLibrary("atl"), "AtlAxWinInit");
LPAtlAxGetControl AtlAxGetControl3 = (LPAtlAxGetControl)GetProcAddress(LoadLibrary("atl"), "AtlAxGetControl");MSG msg; HRESULT hr = AtlAxWinInit3(); HWND hwnd = CreateWindow("AtlAxWin", "", WS\_VISIBLE|WS\_POPUP, 0, 0, 1024, 768, 0, 0, 0, 0); IShockwaveFlash\* flash = 0; hr = CoCreateInstance(\_\_uuidof(ShockwaveFlash), 0, CLSCTX\_ALL, \_\_uuidof(IShockwaveFlash), (void \*\*)&flash); hr = flash->put\_WMode(L"transparent"); hr = flash->put\_Loop(true); hr = AtlAxAttachControl(flash, hwnd, NULL); hr = flash->put\_Movie(L"c:\\\\FrontEnd.swf"); long pVal = -1; flash->get\_ReadyState(&pVal); return true;
}
void FlashViewer::OpenFlash(const char *filename)
{
this->mFlashCtrl->LoadMovie(0, _bstr_t(filename));
}void FlashViewer::DrawToSurface(LPDIRECTDRAWSURFACE7 lpdds)
{
if (this->mViewerWnd == NULL)
return;
RECT rect = {0, 0, this->mViewerWidth, this->mViewerHeight};
HDC hdcSurface;
HRESULT hr = lpdds->GetDC(&am