Visual Basic Web Browser Help

Messages
3,175
http://www.futuregencomputers.com/browser/dannsbrowser - build 007.zip

Yeah, thats the browser I made, quite bootleg but I want to get more features, I was wondering how I would do the following:

Make it so it has aset home page

And

Make it so it can have links like that google one.

Heres a screenshot of the beast: :)

thebeast8ph.jpg
 
dude thats awesome

i was looking at making something cool in visual basic for a project outside of college so far i started a encryption program

i might try and make my own browser now lol ;) sorry to steel the idea

by the links do you mean ones that people can add or ones that are always there?
 
Can I assume that you are using the browser object?
(Webbrowser1).
so to navigate you have a text box called addess
and you navigate to a page you simply call the line
Code:
webbrowser1.navigate address.text
If so there are two ways you could do this...

to set a static home page that you can't change see this code...

Code:
address.text = "http://www.google.com"
webbrowser1.navigate address.text

To have a home page that you can set I suggest you use an INI file to store the variable page...


to do this...

frist create a module insode the program with this code in it
Module1
Code:
' Below function is used to READ from INI file
Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

' Below function is used to WRITE to INI file
Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long


Now put this code into the main form code...

To set the homepage from an address that is in the addressbar (address)

Code:
'global variables
Dim lpAppName As String
Dim lpKeyName As String
Dim lpBuffer As String
Dim lpFileName As String
Dim ret As Long
Dim nSize As Long

Form_load()

temp$ = Dir("C:\windows\browsersettings.ini")
'the file size should only be that of the title, if this has changed the file already exist so take no action.
If temp$ <> "browsersettings.ini" Then

'create blank file
Open "C:\windows\browsersettings.ini" For Output As #1

'print text in INI file
Print #1, "[Homepage]"
Print #1, "address=http://www.google.com"
Close #1 'Close the file...

End If

'Fill the INI variables with the appropriate info...
lpAppName = "Homepage" 'The section of the INI...
lpKeyName = "address" 'The line in the section of the INI...

lpFileName = "C:\windows\browsersettings.ini" 'The location of the INI...

address.text = lpKeyName

End Sub

private Sub Goto-home-page_click()
lpbuffer = space(255)
'read homepage values from INI file
ret = GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, lpBuffer, nSize, lpFileName)

webbrowser1.navigate lzbuffer

endsub

*note this isn't tested...
 
now that would store its permantly yes?

if say the computer was restarted as it would look to that file?
 
yes,
the code looks for the INI file... and if it's not fuond it writes it and stores google as the home page...


next time the user clicks tha home button it'll read that from the INI file and go to whatever the store page is...

I might have got some things wrong, cause it was very much from the top of my head and taken from an old project I was working on... but all the functions are correct... so if it doesn't work, thn a little poking around coding sites will give the answers... at least you have the right questions to ask now though.
 
Back
Top Bottom