Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. AtlAxAttachControl - An outgoing call cannot be made since the application is dispatching an input-synchronous call.

AtlAxAttachControl - An outgoing call cannot be made since the application is dispatching an input-synchronous call.

Scheduled Pinned Locked Moved ATL / WTL / STL
announcementc++adobehelp
6 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bfoo75
    wrote on last edited by
    #1

    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

    S W 2 Replies Last reply
    0
    • B bfoo75

      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

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      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

      B 1 Reply Last reply
      0
      • S Stuart Dootson

        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

        B Offline
        B Offline
        bfoo75
        wrote on last edited by
        #3

        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

        S 1 Reply Last reply
        0
        • B bfoo75

          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

          S Offline
          S Offline
          Stuart Dootson
          wrote on last edited by
          #4

          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

          B 1 Reply Last reply
          0
          • S Stuart Dootson

            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

            B Offline
            B Offline
            bfoo75
            wrote on last edited by
            #5

            Ahhh yikes. Well if you can think of anything let me know. Is there a way I can get the attach control to run thru the message loop? Like posting a custom message?

            1 Reply Last reply
            0
            • B bfoo75

              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

              W Offline
              W Offline
              weir75034
              wrote on last edited by
              #6

              Hi,I think you should add: CComModule _Module; //global CoInitialize(0); _Module.Init(0,GetModuleHandle(NULL)); AtlAxWinInit(); before you call AtlAxAttachControl() function.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups