Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Tutorial - An Internet browser!

combobox

  • Please log in to reply
16 replies to this topic

#1 travy92

travy92

    CC Resident

  • Just Joined
  • PipPipPipPip
  • 73 posts

Posted 09 September 2007 - 11:55 PM

INTRODUCTION

Well basically i've been playing around with a few functions i've learned through other tutorials and i'd like to make a tutorial on making an internet browser with history saving & Menu.

-------------------------------------------------------------------
GUI (LAYOUT)
Here is my GUI:
Posted Image

-------------------------------------------------------------------

What you need:

6 Command buttons with the following Names/Captions:

Command Button #1:
Name: cmdHome
Caption: Home

Command Button #2
Name: cmdBack
Caption: Back

Command Button #3
Name: cmdForward
Caption: Forward

Command Button #4
Name: cmdStop
Caption: Stop

Command Button #5
Name: cmdRefresh
Caption: Refresh

Command Button #6
Name: cmdGo
Caption: Go

1 ComboBox with the following Name/Caption
(Caption is the same as Text... Just find "Text" in the properties window):
Name: cboURL
Caption/Text: (Nothing)

1 Label with the following Name/Caption:

Name: lbCaption
Text: Address:

1 Web Browser with the following Name:

Now for the web browser, you'll need to add the component:
"Microsoft Internet Controls" You can get to the components window by press CTRL+T on the keyboard, then scroll down and tick "Microsoft Internet Controls".

After doing the above procedures, there should be a new item on the list of the tool bar. It looks like the Earth. Now click on it and drag it onto your Form, make it big because it's what you'll be using to view pages with.. Use this Name:
Name: wWeb

If you're having problems like an error when you click "Microsoft Internet Controls" just PM me and i'll help you out.
----------------------------------------------------------------

CODE WITH EXPLANATIONS!

Add this code to cmdHome button (Double click on the Home button to bring up code window.

[quote]Private Sub cmdHome_Click()
wWeb.GoHome
End Sub[/quote]This makes the web browser (wWeb) go to the home page when you click the "Home" button.
(The home page for me is Google, i think it jsut uses your other browser's home page...)

----------------------------------------------------------------

[quote]Private Sub cmdBack_Click()
wWeb.GoBack
End Sub[/quote]This makes the web browser (wWeb) go to the previous page whenever you click the "Back" button.

----------------------------------------------------------------

[quote]Private Sub cmdForward_Click()
wWeb.GoForward
End Sub[/quote]This code instructs the web browser to go to the subsequent page when you click the "Forward" button.

----------------------------------------------------------------

[quote]Private Sub cmdGo_Click()
wWeb.Navigate (cboURL.Text)
cboURL.AddItem (cboURL.Text)
End Sub[/quote]Okay, it's getting a bit harder now.
The above code makes the web browser (wWeb) go to the page specified by the cboURL box (ComboBox).
AND also whatever is entered into the cboURL box is also added to the drop down arrow box (like history).

----------------------------------------------------------------

[quote]Private Sub cmdRefresh_Click()
wWeb.Refresh
End Sub[/quote]This refreshes the web browser when you click the "Refresh" button.

----------------------------------------------------------------

[quote]Private Sub cmdStop_Click()
wWeb.Stop
End Sub[/quote]This code stops the web browser in it's tracks! Basically just stopping it from loading any further.

----------------------------------------------------------------

MENU + CODES

Ok to add a menu to the form you need to go to Tools>Menu Editor or just press CTRL+E.

A window like this will pop-up:
Posted Image


Now add the following in:

[quote]Caption: File
Name: mnuFile[/quote]----------------
Then press "Next"

And then press the Right-Arrow key to make the 3 dots appear:

Add this in:

[quote]Caption: Print
Name: mnuFilePrint[/quote]------------------
Then press "Next"
(Let 3 dots appear):

[quote]Caption: Exit
Name: mnuFileExit[/quote]------------------
Press "Next" again.
(This time take away the 3 dots by pressing the left arrow key)

[quote]Caption: Edit
Name: mnuEdit[/quote]----------------
Press the "Next" button again!
(And make the 3 dots appear again by pressing the right-arrow key)

[quote]Caption: Move
Name: mnuEditMove[/quote]---------------------
Press the "Next" button again!
(Keep the 3 dots):

[quote]Caption: Resize
Name: mnuEditResize[/quote]----------------------
MENU CODE

[quote]'Invoke PrintForm method for this Form (Me)
'Sends image of Form to printer - useful for hardcopy
Private Sub mnuFilePrint_Click()
Me.PrintForm
End Sub[/quote]Basically just prints off the page.

----------------------------------------------------------------

[quote]Private Sub cboURL_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
wWeb.Navigate cboURL.Text
End If
End Sub[/quote]This is an essential code to make the "History" function work.. It makes history work.. Lol.

----------------------------------------------------------------

[quote]Private Sub mnuFileExit_Click()
End
End Sub[/quote]Closes the program.

----------------------------------------------------------------

[quote]'Invoke Move method for this Form (Me)
'Look at Form object --> Methods in Help
Private Sub mnuEditMove_Click()
Me.Move 0, 0

End Sub[/quote]Moves the program window.

----------------------------------------------------------------

[quote]'Parameters of move are: left edge, top edge, width, height
'Measurements in twips (see Lesson 7)
Private Sub mnuEditResize_Click()
Me.Move 6000, 6000, 6000, 5000
End Sub[/quote]Resizes the program.


And if you're lazy and just want the full code:

[quote]Private Sub cboURL_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
wWeb.Navigate cboURL.Text
End If
End Sub

Private Sub cmdBack_Click()
wWeb.GoBack
End Sub

Private Sub cmdForward_Click()
wWeb.GoForward
End Sub

Private Sub cmdGo_Click()
wWeb.Navigate (cboURL.Text)
cboURL.AddItem (cboURL.Text)
End Sub

Private Sub cmdHome_Click()
wWeb.GoHome
End Sub

Private Sub cmdRefresh_Click()
wWeb.Refresh
End Sub

Private Sub cmdStop_Click()
wWeb.Stop
End Sub

Private Sub Form_Load()

Dim Response As Integer



Response = MsgBox("Open Program?", vbInformation + vbYesNo, "Are you sure?")



If Response = vbYes Then
MsgBox "Welcome to Trav's Internet Explorer!"
Load Me

ElseIf Response = vbNo Then

Me.Refresh

End If



End Sub


Private Sub Form_Unload(Cancel As Integer)
Dim Response As Integer



Response = MsgBox("Exit Program?", vbInformation + vbYesNo, "Are you sure?")



If Response = vbYes Then
MsgBox "Thankyou for using Trav's Internet Explorer!"
Unload Me

ElseIf Response = vbNo Then

Me.Refresh

End If



End Sub


'Invoke Move method for this Form (Me)
'Look at Form object --> Methods in Help
Private Sub mnuEditMove_Click()
Me.Move 0, 0

End Sub

'Parameters of move are: left edge, top edge, width, height
'Measurements in twips (see Lesson 7)
Private Sub mnuEditResize_Click()
Me.Move 6000, 6000, 6000, 5000
End Sub

Private Sub mnuFileExit_Click()
End
End Sub

'Invoke PrintForm method for this Form (Me)
'Sends image of Form to printer - useful for hardcopy
Private Sub mnuFilePrint_Click()
Me.PrintForm
End Sub
[/quote]----------------------------------------------------------------

EXTRA

You can also add extra message boxes to the exit buttons just in case you accidentally press Exit.

Here is the code:
[quote]Private Sub mnuFileExit_Click()
Dim Response1 As Integer



Response1 = MsgBox("Exit Program?", vbInformation + vbYesNo, "Are you sure?")



If Response1 = vbYes Then
MsgBox "Thankyou for using Trav's Internet Explorer."
Unload Me

ElseIf Response1 = vbNo Then

Me.Refresh

End If
End Sub[/quote]----------------------------------------------------------------

Or:
[quote]Private Sub Form_Unload(Cancel As Integer)
Dim Response As Integer



Response = MsgBox("Exit Program?", vbInformation + vbYesNo, "Are you sure?")



If Response = vbYes Then
MsgBox "Thankyou for using Trav's Internet Explorer!"
Unload Me

ElseIf Response = vbNo Then

Me.Refresh

End If



End Sub[/quote]----------------------------------------------------------------

Or jsut simply:
[quote]End[/quote](Put this code between the Private Sub "?"_Click ()
and End)
(The "?" stands for the button name... Put the button name in, whatever it is)

----------------------------------------------------------------

THANKS:

Thanks to Tcm9669 for the original Screenshot program.
Thanks to TheComputerMaster for the updated "hidden" version of the Screenshot program.

And thanks to you for taking the time to read this awfully long tutorial.

This tutorial was made by me, Travy92.

Samples!! WOOH!:

Attached Files


  • 2

#2 TcM

TcM

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 10 September 2007 - 12:16 AM

Thanks for the Credits :) and now your screen shots are way better :)
  • 0

#3 travy92

travy92

    CC Resident

  • Just Joined
  • PipPipPipPip
  • 73 posts

Posted 10 September 2007 - 12:31 AM

Thanks for the Credits :) and now your screen shots are way better :)


Yeah no problems! I agree, my screenshots are way better!
  • 0

#4 codeman123

codeman123

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 03 November 2007 - 12:40 AM

thaaaaanks
nice work
  • 0

#5 vonhell

vonhell

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 08 December 2007 - 07:34 AM

Great program thank:)
  • 0

#6 $RaMRoM$

$RaMRoM$

    CC Lurker

  • Just Joined
  • Pip
  • 5 posts

Posted 13 January 2008 - 09:40 AM

I love this tutorial, Thanks a lot!
  • 0

#7 GnBz

GnBz

    CC Lurker

  • Just Joined
  • Pip
  • 3 posts

Posted 15 January 2008 - 10:13 AM

looks cool i will cheak it out
  • 0

#8 juelpatwary

juelpatwary

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 24 January 2008 - 09:11 AM

Truely great, Thanks...
  • 0

#9 Colin5555

Colin5555

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 17 February 2008 - 07:10 PM

Great Tutorial, thanks
  • 0

#10 miamia

miamia

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 30 November 2008 - 02:01 PM

great!
  • 0

#11 leetjordan

leetjordan

    CC Lurker

  • Just Joined
  • Pip
  • 4 posts

Posted 10 December 2008 - 11:25 AM

yes thank you sir nice post
  • 0

#12 mendim.

mendim.

    CC Devotee

  • Just Joined
  • PipPipPipPipPipPip
  • 741 posts

Posted 10 December 2008 - 12:53 PM

Great Tutorial .. (Y)
I made an Internet Browser before but much Simple ..
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download