Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 73,389 times

Contents

Related Categories

WebBrowser Control - Browser Commands

Paul Hughes

Browser Commands

Now then The Nitty-Gritty. Opening, Saving and Printing in the web browser. In the menu editor create 3 new options called mnuopen, mnusave and mnuprint. Give them a caption related to their functions, i.e. open, save and print. Now then here is when it gets a bit silly. You now use more functions of Internet Explorer to do these things, as the Common Dialog function doesn’t work at all

Select the options and type in the following in each sub (which I have also labelled so now confusion could happen)

Private Sub mnuOpen_Click()
    '// tell the web browser control to prompt the user
    '// for a file to open
    On Error Resume Next
    WebBrowser1.ExecWB OLECMDID_OPEN, OLECMDEXECOPT_PROMPTUSER
End Sub

Private Sub mnuPrint_Click()
    '// tell the web browser control to print the current page
    On Error Resume Next
    WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER
End Sub

Private Sub mnuSave_Click()
    '// tell the web browser to save the page
    On Error Resume Next
    WebBrowser1.ExecWB OLECMDID_SAVEAS, OLECMDEXECOPT_PROMPTUSER
End Sub

Now then if all went well then you see this thing:

And all the controls work as well can be!!

You will notice that both the Save, Open and Print commands all used the ExecWB method of the WebBrowser. This function also as some extra functionality, not covered yet. In the table below, I have listed all the other constants you can pass (that I can get to work)... have a try!

Constant Name Value Action...
OLECMDID_SAVEAS 4 Displays the save as dialog
OLECMDID_PRINT 6 Displays print dialog
OLECMDID_PAGESETUP 8 Displays page setup dialog
OLECMDID_PROPERTIES 10 Displays page properties dialog
OLECMDID_SELECTALL 17 Selects all the text in the active frame or page
OLECMDID_REFRESH 22 Reloads the page
OLECMDID_COPY 12 Copies the selected text
OLECMDID_STOPDOWNLOAD 30 Stops the current download

You can also see that at the moment, our web browser doesn't look very 'pretty'. To improve this, you could use the Toolbar control, and generally enhance the user interface. Why not have a go?

You can download the source code here, or if you have perhaps have other queries then you can email me at paul@thtproductions.co.uk with web browser tutorial in the subject line. Well then that’s all folks!!!

Paul Hughes

Http:\www.thtproductions.co.uk

Comments

  • Re: [18] WebBrowser Control

    Posted by DeviledGod on 02 Jul 2008

    Hi...I want some help about WebBrowser controls. More specifically i want to know how the URL textbox changes and gets the Browser's URL.


    When i click a link...

  • Re: [18] WebBrowser Control

    Posted by borqom on 06 May 2008

    Hi, As i know so far there is no go button, to create a button that takes you to a link you have to use a textbox (txtLink) and a button(btnlink) controls.


    I...

  • Re: [18] WebBrowser Control

    Posted by OsamaPs on 17 Jul 2006

    hi


    it is a great browser :D


    but where is th GO button?!!?!

  • Posted by ooo on 07 Nov 2005

    hey try to be more discrete i know hwo u are :)

  • Command in webbrowser

    Posted by Mikey123 on 05 Oct 2005

    Hi,
    I have created a web browser for it to load tankmania.com but what i need to know is how do i get a button to interact with the web browser eg: I click the button and it send a keyboard event to ...