CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Guest

    How to use WebBrowser Control

    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.


  2. #2
    Join Date
    May 1999
    Location
    nz
    Posts
    96

    Re: How to use WebBrowser Control

    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

  3. #3
    Guest

    Re: How to use WebBrowser Control

    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.


  4. #4
    Join Date
    May 1999
    Location
    nz
    Posts
    96

    Re: How to use WebBrowser Control

    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

  5. #5
    Join Date
    Apr 1999
    Location
    Germany
    Posts
    418

    Re: How to use WebBrowser Control

    Hi,

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

    Martin

  6. #6
    Guest

    Re: How to use WebBrowser Control

    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.


  7. #7
    Guest

    Re: How to use WebBrowser Control

    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


  8. #8
    Join Date
    May 1999
    Location
    nz
    Posts
    96

    Re: How to use WebBrowser Control

    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:ut_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

  9. #9
    Join Date
    Jan 2006
    Posts
    50

    Re: How to use WebBrowser Control

    Quote Originally Posted by Colin Davies
    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:ut_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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured