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?
bfoo75
Posts
-
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.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
-
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 -
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 -
Converting System.Drawing.Image to a DirectDrawSurfaceSolved the problem... the Bitmap class can be cast into an HBITMAP & then selected as an HDC to be copied into the surface. Heres the fixed code:
MemoryStream^ ms = gcnew MemoryStream(br->ReadBytes(TILE_BITMAPSIZE));
Bitmap^ bm = gcnew Bitmap(Image::FromStream(ms, true, true));
HBITMAP hbm = (HBITMAP)bm->GetHbitmap().ToPointer();HDC src = CreateCompatibleDC(NULL);
SelectObject(src, hbm);
HDC dst;BitBlt(dst, 0, 0, Width, Height, src, 0, 0, SRCCOPY);
-
StreamWriter - How can I write as a .CSV file ?When you open the file in Excel, open it as a comma delimited file and set the parse character to a comma.
-
Converting System.Drawing.Image to a DirectDrawSurfaceHi - I've saved a System.Drawing.Image to a file stream from C# and now I'm trying to load it in Managed C++... I have some other data that is included inbetween the bitmap data in the filestream and when I blt the surface to the backbuffer, the surface thats supposed to hold the bitmap data is entirely black. :-/
Tiles[i].Init(lpDD7); //Creates the DD7 Surface
bool Walkable = br->ReadBoolean();
MemoryStream^ ms = gcnew MemoryStream(br->ReadBytes(TILE_BITMAPSIZE));
Image^ bm = Image::FromStream(ms, true, true);
Graphics^ g = Graphics::FromImage(bm);
IntPtr^ hDC = g->GetHdc();
HDC src = static_cast<HDC>(hDC->ToPointer());
HDC dst;Tiles[i].Walkable = Walkable;
Tiles[i].Surface->GetDC(&dst);
BitBlt(dst, 0, 0, 32, 32, src, 0, 0, SRCCOPY);
Tiles[i].Surface->ReleaseDC(dst);Heres the INIT function
void Init(LPDIRECTDRAW7 lpDD7) { DDSURFACEDESC2 ddsd; INIT\_DXSTRUCT(ddsd); ddsd.dwFlags = DDSD\_CAPS | DDSD\_HEIGHT | DDSD\_WIDTH; ddsd.ddsCaps.dwCaps = DDSCAPS\_OFFSCREENPLAIN; ddsd.dwWidth = 32; ddsd.dwHeight = 32; HRESULT hr = lpDD7->CreateSurface(&ddsd, &Surface, NULL); }
Thanks.
-
String Formatting when PrintingThanks Luc, That did the trick. I was trying to use system before because I thought it was lined up, but courier worked beautifully.
-
String Formatting when PrintingHi everyone, I'm running into a problem while trying to format strings for printing. I'm working heavily with finance and I need the values to be flushed right and formatted as cash. Unfortunately none of the values are being formatted correctly. I assumed that if the String.Format() function was used correctly that the string would be returned with all the information needed to line it up correctly. I ran into a similar problem when trying to line up information in combo boxes. What I think is going on is that the width of a space is much smaller then the width of the characters in a font. Does anyone know of a workaround for this? Thanks. - Will
-
Suggestion for C# compatible languageHi All I've just joined a project that is going to require a heavy load of optimization. I'm looking for a language that is compatible with C# that compiles into machine code. At the moment, our plan involves a number of nested loops to which we are hoping to write in machine code. Would C++ work for this? Thanks.