You will have noticed that in explorer, there are far more buttons than just Back and Forward, so lets add them now. Alongside the first 2 buttons (forward and back) place four new command buttons called cmdstop, cmdhome, cmdsearch and cmdrefresh. In the caption properties, call them stop, home, search and refresh (or something else if you want). Double click on each of them and add the following code for each button….
HOME
WebBrowser1.Navigate "http:\www.thtproductions.co.uk"
STOP
WebBrowser1.Stop
SEARCH
Webbrowser1.gosearch
REFRESH
Webbroswer1.stop
Now then You by now have noticed that if you resize the for the web browser window doesn’t resize with it. To get this to work, all you need to do is type in the code below into the Resize event of the Form, and the window will resize automatically with the window.
WebBrowser1.Move 0, 0, ScaleWidth, ScaleHeight
You can also simply set the Width and Height properties instead, if you wish.
However, now you will notice the problem below:
It would seem only way to get around this is to pull the webbrowser window to the top of the form as high as it will allow (i.e. the top of the browser window meets the part of the form with the little icon and the name of the form in the little bar.) But then when you run the program again you will find that the buttons are over the web browser window. Bummer. Never fear Paul is here. In order to get things right again all you need to do is to take into account the space taken up by the buttons and combo box when the form is resized. To do this, all you need to do is change the code in the Resize event to
'resize the webbrowser control to fill the window (ScaleWidth and ScaleHeight)
'840 is the space taken up by the buttons!
WebBrowser1.Move 0, 840, ScaleWidth, ScaleHeight - 840
Simple!
Comments