Click to See Complete Forum and Search --> : How to use WebBrowser Control


September 24th, 1999, 11:05 AM
I have following questions about WebBrowser Control:
1) Normally, WebBrowser Control will take care the navigation in a Web Page (mouse click or keyboard TAB). How about I don't have those devices, and I know the location of a hyperlink or FORM submit button, can I send a message directly to WebBrowser control, I try to send a WM_LBUTTONDOWN to CHtmlview class, and it won't work?
2) If this is impossible, can I get the hyperlink information from WebBrowser control?
3) How can I get rid of the vertical scroll bar browser usually have?
4) How to change the default MFC Document/View Windows Style with my own?
Thanks.

Colin Davies
September 26th, 1999, 08:16 PM
Hi
Yes for 1, 2, 3
if you are hosting the webbrowser control and MSHTML
Unfortunatly I believe you are using CHtmlView which I don't believe you can modify as much
as you wish. CHtmlView is cumbersome as I believe it inherits from CFormView
Try hosting it in a dialog app.
For 1. Try Posting data in the Navigate or Navigate2
For 2. Use IHTMLDocument2::get_links for the element collection
For 3 Change the DOCHOSTUIFLAG s with the IDocHostUIHandler
For 4 Hey if its a Dialog App you can make it look like a Dougnut or
whatever else easily.

Have fun




regardz

Colin Davies

September 27th, 1999, 03:29 PM
Thanks so much. So far I made most of the job, one thing left:
Since I don't have mouse and key board, if seomone send me a message "Click at Window CPoint(300,200)" (which has an unknown hyper link), How can I transfer this message to Web Browser Control. I check its Events and did not figure out how I can do it. If I know the URL I can use "Navigate()" method. But since the web page is unpredictable and I don't know if it is an URL or a FORM submit button. Also, I can not send a WM_LBUTTONDOWN message myself since it is ActiveX control (right?)
The only thing I can think now is using IHTMLDocument2::get_links to get all element collection and try to parse it. Is it the only solution?
Thanks.

Colin Davies
September 27th, 1999, 06:43 PM
Umm
I'm a bit confused how you navigate it without a mouse or keyboard.
If I'm correct you are trying to "automate" the webrowser - control ??
Please respond if I am right or wrong !
I honestly consider click at Window CPoint(xxx,yyy) to be a incredibly difficult way of solving anything with MSHTML
STATUSTEXTMESSAGE event should show you the latest link that the webbrowser was at. (Apart from some "Image Maps and content tables" etc")
Could you post some more detailed information on what you are trying to achieve and why .. And just Maybe I can help. Maybe not also.

Regardz
Colin Davies

regardz

Colin Davies

Martin Speiser
September 28th, 1999, 03:44 AM
Hi,

you can get the IHTMLDocument2 interface by calling the GetHtmlDocument member function of CHtmlView.

Martin

September 28th, 1999, 08:15 AM
This is an embedded application with Windows CE (2.12 will have IE 4.0 and Web BRowser control). It looks like the ATM machine, intead show the text strings, it will show a HTML page, when customer presses "ARROW" key around the ATM screen, it means to show another page (hyperlink or a submit button). In the embedded world like the ATM machine, there don't have the mouse/keyboard those Desktop standard input device.

Here is a simple example:

Keys outside the screen | Screen (shown HTML page)
----------------------------------------------------
< | Withdraw Press Here
< | Deposit Press Here
< | For Help, Press Here
--------------------------------------------------
The HTML page will look like:
...
<BODY>
<table width="100%" height="100%">
<tr>
<td><A HREF="withdraw.htm">Withdraw Press Here</A></td>
</tr>
<tr>
<td><A HREF="deposit.htm>Deposit Press Here</A></td>
</tr>
<tr>
<td><A HREF="help.htm">For Help, Press Here</A></td>
</tr>
</table>
</BODY>...

The text shown on screen each will have a hyper link. User can send me an "ARROW" key pressed message ("ARROW" key is general I/O). The question is after I receive an "ARROW" key pressed message, how to let the Web Browser control think there is a mouse click event, and then it displays next page (withdraw.htm for example). If it's simply like this, I can predict next URL will be and call "navigate", but the actual application will be much complicated and I can't predict the URL (or the "ARROW" key may means a FORM submit button). I think this is the difficult part. I don't know if I can send an message directly to the ActiveX control from the container?

Thanks for your help.

October 2nd, 1999, 06:13 PM
One more thing for IDocHostUIHandler.
I tried:
m_IDisp = m_browser.GetDocument();
m_IDisp->QueryInterface (IID_IDocHostUIHandler, (void**)&m_HostUI);
But the m_HostUI is NULL.
1. How to get the IDocHostUIHandler interface, I included <mshtmhst.h>, do I need <mshtmhst.idl>?
2. DO I need to implement method "GetHostInfo" to change the FLAG?
Thanks

Colin Davies
October 2nd, 1999, 07:41 PM
Hi,
Look it been a while since I played with this.
And I can only remember the general concepts involved.
Some stuff that might help you.
I suggest a good book is Scott Roberts Programming Internet Explorer5
ISBN 0-7356-0781-8
Sorry I haven't got any old code on how its done.
Or try searching Deja.com for NewsGroup microsoft.public.inetsdk.programming.webbrowser_ctl
As this question has been discussed there before.
And possibly for your other post IHTMLDocument2::put_onclick might help,
I've never had need to use it, so I wouldn't know for sure.
I'm sure if you can get the webbrowser-ctl to work for this app you'll end up with a far more user friendly and colorful looking front-end.
Also a trick I learnt at hiding the scroll bars, build a dialog box app with webbrowser-ctl embedded. Then on initiation resize the browser control to be 18 pixels bigger than the dialog-box. This effectivly hides the scroll bars. "I know it isn't a professional approach" but it does work :-)
Good-Luck
and Regardz
Colin Davies

regardz

Colin Davies

mariposo
August 31st, 2006, 12:09 AM
Hi,
Look it been a while since I played with this.
And I can only remember the general concepts involved.
Some stuff that might help you.
I suggest a good book is Scott Roberts Programming Internet Explorer5
ISBN 0-7356-0781-8
Sorry I haven't got any old code on how its done.
Or try searching Deja.com for NewsGroup microsoft.public.inetsdk.programming.webbrowser_ctl
As this question has been discussed there before.
And possibly for your other post IHTMLDocument2::put_onclick might help,
I've never had need to use it, so I wouldn't know for sure.
I'm sure if you can get the webbrowser-ctl to work for this app you'll end up with a far more user friendly and colorful looking front-end.
Also a trick I learnt at hiding the scroll bars, build a dialog box app with webbrowser-ctl embedded. Then on initiation resize the browser control to be 18 pixels bigger than the dialog-box. This effectivly hides the scroll bars. "I know it isn't a professional approach" but it does work :-)
Good-Luck
and Regardz
Colin Davies

regardz

Colin Davies

Hi Colin,

How can I programatically execute the "Back/left arrow" button on the tool bar of the IE browser. I use C#. Thanks.

mariposo