Make a Moderate Web-Browser - Part 2


Ok, here is part2 of how 2 make a moderate web browser. you can either download the 1st 1/2 or use the tutorial

Tut:https://tutorial.ninja/tutorials/Desktop+Programming/Visual+Basic/271/Make+a+Moderate+WebBrowser.html


_________________


OK, First lets add a search. Make 1 text box and 3 buttons. Name the Textbox SB and the buttons s01 s02 and s03. Now add this code:
VISUALBASIC Code
  1. Private Sub s01_Click()
  2. w.Navigate "https://www.google.com/search?q=" & SB.Text
  3. End Sub
  4.  
  5. Private Sub s02_Click()
  6. w.Navigate "https://search.yahoo.com/search?p=" & SB.Text
  7. End Sub
  8.  
  9. Private Sub s03_Click()
  10. w.Navigate "https://search.msn.com/results.aspx?q=" & SB.Text
  11. End Sub


Ok, that is how you do add the searches.

________________

Now lets add history. Make another form called "form3"

add a combo box to it named "CB"

Now in the menu editor, make 1 named "G" and captioned "history". Add the following code:
VISUALBASIC Code
  1. Private Sub w_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
  2. On Error Resume Next
  3. Dim I As Integer
  4. Dim bFound As Boolean
  5. Me.Caption = w.LocationName & " - Zar Browser"
  6. T.Text = w.LocationURL
  7. For I = 0 To Form3.CB.ListCount - 1
  8. If Form3.CB.List(I) = w.LocationURL Then
  9. bFound = True
  10. Exit For
  11. End If
  12. Next I
  13. mbDontNavigateNow = True
  14. If bFound Then
  15. Form3.CB.RemoveItem I
  16. End If
  17. Form3.CB.AddItem w.LocationURL, 0
  18. Form3.CB.ListIndex = 0
  19. mbDontNavigateNow = False
  20. End Sub
  21.  
  22. Private Sub G_Click()
  23. Form3.Visible = True
  24. End Sub

Now, when you navigate to a site, the URL will go to the adressbar, and the Name will go to the title of the browser as well as the history being recorded.

___________________

Now to block popups. Its pretty simple, just add this code:
VISUALBASIC Code
  1. Private Function IsPopupWindow() As Boolean
  2. On Error Resume Next
  3. If w.Document.activeElement.tagName = "BODY" Or w.Document.activeElement.tagName = "IFRAME" Then
  4. IsPopupWindow = True
  5. Else
  6. IsPopupWindow = False
  7. End If
  8. End Function
  9.  
  10. Private Sub w_NewWindow2(ppDisp As Object, Cancel As Boolean)
  11. Dim frm As Form1
  12. Cancel = IsPopupWindow
  13. If Cancel = False Then
  14. Set frm = New Form1
  15. Set ppDisp = frm.w.object
  16. frm.Show
  17. End If
  18. End Sub

now you pop the blockups.

________________________

O yeah, and i found out in the other browser, the properties and print dont work, so add this code instead:
VISUALBASIC Code
  1. Private Sub C_Click()
  2. w.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DODEFAULT
  3. End Sub
  4.  
  5. Private Sub D_Click()
  6. w.ExecWB OLECMDID_PROPERTIES, OLECMDEXECOPT_DODEFAULT
  7. End Sub



You can also add an open option. Go to menu editor and add an option called "Open". Name it "L"
now add this code:
VISUALBASIC Code
  1. Private Sub L_Click()
  2. w.ExecWB OLECMDID_OPEN, OLECMDEXECOPT_DODEFAULT
  3. End Sub


____________________________

Now you can add some Edit commands. Like copy, paste, cut, and so forth.
Go to menu Editor, and do this:

Edit (name=M)
....Undo (name=N)
....Redo (name=O)
.... (Uncheck enabled)(name=P)
....Cut (name=Q)
....Copy (name=R)
....Paste (name=S)
....Delete (name=U)
....Find (name=v)

Now add this code:
VISUALBASIC Code
  1. Private Sub N_Click()
  2. w.ExecWB OLECMDID_UNDO, OLECMDEXECOPT_DODEFAULT
  3. End Sub
  4.  
  5. Private Sub O_Click()
  6. w.ExecWB OLECMDID_REDO, OLECMDEXECOPT_DODEFAULT
  7. End Sub
  8.  
  9. Private Sub Q_Click()
  10. w.ExecWB OLECMDID_CUT, OLECMDEXECOPT_DODEFAULT
  11. End Sub
  12.  
  13. Private Sub R_Click()
  14. w.ExecWB OLECMDID_COPY, OLECMDEXECOPT_DODEFAULT
  15. End Sub
  16.  
  17. Private Sub S_Click()
  18. w.ExecWB OLECMDID_PASTE, OLECMDEXECOPT_DODEFAULT
  19. End Sub
  20.  
  21. Private Sub U_Click(Index As Integer)
  22. w.ExecWB OLECMDID_DELETE, OLECMDEXECOPT_DODEFAULT
  23. End Sub
  24.  
  25. Private Sub V_Click()
  26. w.ExecWB OLECMDID_FIND, OLECMDEXECOPT_DODEFAULT
  27. End Sub


I now took the time 2 add shortcuts to all of the menu links. You may do so if you please. just choose something under "shortcut:"

_____________________________

now you can jazz up your webbrowser. Add anything you like. If this tutorial is too hard or something 2 read (which i know im bad at making tuts), then you can just download the source.
zar's Avatar
Author:
Views:
3,104
Rating:
Posted on Thursday 27th December 2007 at 03:01 PM
Dalez
Dalez's Avatar
The history doesn't work, and the most of the edit doesn't. Also, I can't get the buttons to work (1st tut) keeps saying that the code is wrong. Atm i'm using no buttons
Posted on Thursday 27th December 2007 at 03:01 PM
Dalez
Dalez's Avatar
The history doesn't work, and the most of the edit doesn't. Also, I can't get the buttons to work (1st tut) keeps saying that the code is wrong. Atm i'm using no buttons
Posted on Tuesday 4th December 2007 at 10:57 PM
zar
zar's Avatar
o yeah, u have 2 make the Name for find a capital V. u probably made it lower case


sorry for 3rd comment :(
Posted on Tuesday 4th December 2007 at 10:52 PM
zar
zar's Avatar
i found out that open isnt supported anymore :( but it still displays it as correct in code.
Posted on Tuesday 4th December 2007 at 10:49 PM
zar
zar's Avatar
code for find:

Code
Private Sub V_Click()
w.ExecWB OLECMDID_FIND, OLECMDEXECOPT_DODEFAULT
End Sub


open is being stupid :(
Posted on Tuesday 4th December 2007 at 12:10 AM
ShadowMage
ShadowMage's Avatar
Sorry for double comment but find doesnt either o.o
Posted on Monday 3rd December 2007 at 11:57 PM
ShadowMage
ShadowMage's Avatar
Open doesn't work for me o.o