AtlAxAttachControl - An outgoing call cannot be made since the application is dispatching an input-synchronous 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 -
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(&amI suspect that it's a COM threading issue. Do you have a single threaded app or maybe a single-threaded apartment model app? Is FlashViewer::Init called from within a COM method?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
I suspect that it's a COM threading issue. Do you have a single threaded app or maybe a single-threaded apartment model app? Is FlashViewer::Init called from within a COM method?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
Its a single threaded app but I think you might have something on the apartment model. I'm using this as a control inside a WIN32 window. The odd thing is that the FlashViewer::Init still throws the same error even if its executed before the WIN32 window is declared. The other strange thing is that this code executes if its included on its own like this:
#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);int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmd, int show)
{
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; IViewObject\* view = 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"); hr = flash->QueryInterface(\_\_uuidof(IViewObject), (void \*\*) &view); long pVal = -1; flash->get\_ReadyState(&pVal); BSTR val = L"Null", var = L"GetLastButton"; string cval; while(GetMessage(&msg, 0, 0, 0) && flash) { hr = flash->CallFunction(L"<invoke name=\\"GetLastButton\\" returntype=\\"string\\"></invoke>" , &val); cval = \_com\_util::ConvertBSTRToString(val); if (cval.compare("<string>btnQuit</string>") == 0 ) { PostMessage(hwnd, WM\_QUIT, NULL, NULL); } DispatchMessage(&msg); }
};
I tried using OleInitialize(NULL); at the start of the INIT function which is supposed to call CoInitializeEx with COINIT_APARTMENTTHREADED. But I still got the same problem. Heres my shell for the windows app (excuse the amount of code):
WIN32APP.H
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#pragma once
#define SCREEN_WIDTH 1024
#define SCREEN_HEIGHT 768
#define COLOR_DEPTH 32#de
-
Its a single threaded app but I think you might have something on the apartment model. I'm using this as a control inside a WIN32 window. The odd thing is that the FlashViewer::Init still throws the same error even if its executed before the WIN32 window is declared. The other strange thing is that this code executes if its included on its own like this:
#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);int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmd, int show)
{
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; IViewObject\* view = 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"); hr = flash->QueryInterface(\_\_uuidof(IViewObject), (void \*\*) &view); long pVal = -1; flash->get\_ReadyState(&pVal); BSTR val = L"Null", var = L"GetLastButton"; string cval; while(GetMessage(&msg, 0, 0, 0) && flash) { hr = flash->CallFunction(L"<invoke name=\\"GetLastButton\\" returntype=\\"string\\"></invoke>" , &val); cval = \_com\_util::ConvertBSTRToString(val); if (cval.compare("<string>btnQuit</string>") == 0 ) { PostMessage(hwnd, WM\_QUIT, NULL, NULL); } DispatchMessage(&msg); }
};
I tried using OleInitialize(NULL); at the start of the INIT function which is supposed to call CoInitializeEx with COINIT_APARTMENTTHREADED. But I still got the same problem. Heres my shell for the windows app (excuse the amount of code):
WIN32APP.H
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#pragma once
#define SCREEN_WIDTH 1024
#define SCREEN_HEIGHT 768
#define COLOR_DEPTH 32#de
My suspicion would still be threading - and something to do with the message loop. I suspect the Flash control uses one or more threads other than the main UI thread. In that situation, Windows uses window messages to transfer control between threads. Other than that, I can't really think of any specific advice - sorry :-(
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
My suspicion would still be threading - and something to do with the message loop. I suspect the Flash control uses one or more threads other than the main UI thread. In that situation, Windows uses window messages to transfer control between threads. Other than that, I can't really think of any specific advice - sorry :-(
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
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