The IntemetExplorer object allows yOu to start an instance of Internet Explorer from within your application and manipulate it througll OLE Automation. The Internet- Explorer object ~pports the same properties and methods as the WebBrowser control, plus a few more. Wewill look at the object’s properties and methods shortly, but ,first let’s build an application that controls Internet Explorer. It’s called IExplore, and . you wiD find it on the CD.
VB6 at Work: The Expoler Project
To reference Internet Explorer from within your project, you must first add’ a reference to the IntemetExplorer object Follow these steps: .
1 Start a neW ‘project aI)d select S~dard .EXEas the project type.
2. Choose Project >References to open the refrences dialog box:
3. Check the Microsoft Internet Controls cheekbox,
This time, you won’t see a new icon in the Toolbox: But if you open the Object browser window you will see that the InternetExplorer Class has the In’the Members windQw, you will ‘see the properties and methods exposed by the IntemetExplorer oUs, andJhrough these members you can OLE automate the Internet Explorer appUccttion. Let’s build an application that will ccntrol one or more instances of Internet. Explorer. The application is shown in Figure 21.3. The user can select destination in the ComboBox control in the Visual Basic window and click the Show URL button to start an instance of Internet Explorer, in which the selected URL is displayed.
To continue building the application, follow these steps:
4. Design a Form like the one shown in Figure 21.3.
5. Declare a Form-wide object variable, though which you’ll be accessing the members of the InternetExplorer Class:
Dim IE As New InternetExplorer
6 Now add the following initialization code in the Form’s Load event:
Private Sub Form_Load()
List1.AddItem ‘microsoft’
Listl.Addltem ‘sybex’
Listl.Addltem ‘infoseek’
Listl.Addltem ‘realaudio’
End Sub
The most interesting part of this application is the code behind the Show URL Command button, which loads an instance of Internet Explorer and opens the selected URL in its window .
The Show URL Button
The ToolBar and MenuBar properties determine whether the toolbar and menu bar of Inrernet Explorer will be visible.. Notice that the Internet Explorer window shown in Figure 21.3, earlier in this chapter, has neither a toolbar nor a menu bar. The Navigate method opens the specified document and displays it in.the browser’s window. (111discuss the properties and the inethods of the IntemetElorer object and the WebBrowser control in the next section.) The Back and Forward buttons are implemented with two methods of the Internet Explorer object, GoBack and Gof’OrWard.
The Show URL Button
The ToolBar and MenuBar properties determine whether the toolbar and menu bar of Inrernet Explorer will be visible.. Notice that the Internet Explorer window shown in Figure 21.3, earlier in this chapter, has neither a toolbar nor a menu bar. Tne Navigate method opens the specified document and displays it in.the browser’s window. (111discuss the properties and the inethods of the IntemetE~lorer object and the WebBrowser control in the next section.) The Back and Forward buttons are implemented with two methods of the Internet- Explorer object, GoBack and Gof’OrWard.