I added the WebBrowser component to my toolbox,
then placed one on a form with other .NET components.
This much seems to have worked, but I do not understand
how to control the sucker from within my application.
Specifically, what sort of syntax is involved to get the
various interfaces (IHTMLWindow, IHTMLDocument3, etc)
in the internal objects and call functions in them?
What has worked is this:
A: the framework put the following in the form class:
private: AxInterop::SHDocVw::AxWebBrowser* browser;
B: the framework put the following in the InitializeComponent()
part of the form class:
this->browser = new AxInterop::SHDocVw::AxWebBrowser();
(__try_cast<System::ComponentModel::ISupportInitia lize*>(this->browser))->BeginInit();
and elsewhere
this->browser->Enabled = true;
this->browser->Location = System::Drawing::Point(400, 24);
this->browser->OcxState = (__try_cast<System::Windows::Forms::AxHost::State * >(resources->GetObject(S"browser.OcxState")));
this->browser->Size = System::Drawing::Size(360, 176);
this->browser->TabIndex = 3;
including this because I added one event handler:
this->browser->DocumentComplete += new AxInterop::SHDocVw::DWebBrowserEvents2_DocumentCom pleteEventHandler(this,
web_browser_event_document_complete);
So, here we are in an event handler, and no matter what I try
off the top of my head, it doesn't work. I can call some of
the immediately available methods like the one shown below,
but how to deal with the document variable is what I don't get.
How do I get IHTMLWindow3 and IHTMLDocument3 and such
in order to get at the document and its html-text and such?
And how do I find out what I CAN get, in general? Is there
some way to make the framework show what can be done,
like with normal methods.
Thanks in advance:
private: System::Void web_browser_event_document_complete (System::Object* sender,
AxInterop::SHDocVw::DWebBrowserEvents2_DocumentCom pleteEvent* e) {
System::Object* document = browser->get_Document();
int a = 0;
}