What's the trick to get ActiveXControlComponent to work


#1

I’m trying to create an activeX control in Juce using the following code inside the parent component’s constructor:

myAxControl = new ActiveXControlComponent();
IID myIID;
IIDFromString(L"{8856f961-340a-11d0-a96b-00c04fd705a2}", &myIID); //IE browser control
myAxControl->setBounds(0,0,200,200);
addAndMakeVisible (myAxControl);
myAxControl->createControl(&myIID);

I keep getting an assertion at juce_win32_Windowing.cpp line 3436:

// the component must have already been added to a real window when you call this! jassert (dynamic_cast <Win32ComponentPeer*> (peer) != 0);

Seems like I’m doing what is suggested in the Juce docs. Any ideas what I’m missing?


#2

heres a brutally simple browser I did (that got abandoned in favor of just using IE!)

[code]#include <juce.h>
#include <exdisp.h>
#include <comutil.h>

class HTMLPane : public Component
{
ActiveXControlComponent* control_;
IWebBrowser2* browser_;

public:
HTMLPane()
: browser_ (0)
{
setName( T(“Browser”) );
addAndMakeVisible( control_ = new ActiveXControlComponent() );
}

~HTMLPane()
{
	if ( control_->isControlOpen() )
	{
		control_->deleteControl();
		browser_->Release();
	}

	deleteAllChildren();
}

bool initialise()
{
	static bool init = false;

	if ( init ) return true;

	if ( control_->createControl (&CLSID_WebBrowser) )
	{
		browser_ = (IWebBrowser2*) control_->queryInterface ( &IID_IWebBrowser2 );

		init = browser_ != 0;

		return init;
	}
	else
	{
		return false;
	}
}

bool loadPage( const String& path )
{
	_bstr_t bstr1 ( (const char *)path );
	BSTR address = bstr1.copy();
	HRESULT hr = browser_->Navigate( address, NULL, NULL, NULL, NULL );

	return hr == S_OK;
}

void resized()
{
	control_->setBoundsInset( BorderSize() );
}

};[/code]

its a tad underdeveloped to say the least!


#3

Hi,
I embedded your sample activeX browser component in a window, but I just see an empty window:

struct MainWindow : public DocumentWindow
{
MainWindow()
:
DocumentWindow(
T(“Juce test”),
Colours::white,
DocumentWindow::allButtons,
true )
{
setResizable( true, false );
setTitleBarHeight( 20 );

  //TextEditor* textEditor = new TextEditor;
  //textEditor->setText( "test" );
  //setContentComponent( textEditor );

  HTMLPane* htmlPane = new HTMLPane;
  setContentComponent( htmlPane );
  htmlPane->initialise();
  htmlPane->loadPage( "www.google.com" );

}
virtual void closeButtonPressed() {}
};

By replacing the activeX component by a simple text editor component I at least see the “test” text.
Anything else I have to consider with my project (vc8) to make it work?

Hope for help,

Boris


#4

You need to set a size to the main window and component.
Please have a look to the Juce demo Quicktime Component source code.


#5

[quote]You need to set a size to the main window and component.
Please have a look to the Juce demo Quicktime Component source code.[/quote]
Fine, I have managed to see the web browser activeX component now. But what I really want to achieve is to use the chart activeX component 7.0 by Steema software. I like to migrate from wxWidgets to juce. With wxWidgets I use the wxActiveX component to display the TChart object, but replacing the web browser by the TChart component in my juce sample project does not work. Calling createInstance and queryInterface succeeds but the chart just not display.
I know this problem is quite specific, but is there anything else I can try?

Regards,

Boris


#6

Are you sure it’s not just that you need to call some specific functions belonging to this chart object to make it work?


#7