|
-
Jan 22nd, 2005, 01:40 AM
#1
Thread Starter
Lively Member
Help me please!!
I have a few questions, about VB because i just startd about a day ago.
How do I make a program open up internet explorer links, inside of it (like an iframe on a website).
Also, if anyone could help me get startd that would be greatly appreciated.
Last edited by K1tchen; Jan 24th, 2005 at 11:29 PM.
-
Jan 22nd, 2005, 01:58 AM
#2
Re: Help me please!!
the easiest way would be to use SHELL "www.vbforums.com"
which would open your default browser. The next best way it to use SHELLEXECUTE, but you need to load some stuff before you can use it.
Click the search button and type it in. There is another thread on the first page from today that lists out exactly what you would need to do it the second way.
Welcome to the forums.
-
Jan 22nd, 2005, 08:06 PM
#3
Thread Starter
Lively Member
Re: Help me please!!
thanks, ill let you know if it works
edit: it didnt work
any other ideas?
-
Jan 22nd, 2005, 08:17 PM
#4
Re: Help me please!!
VB Code:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_HIDE As Long = 0
Private Const SW_SHOWNORMAL As Long = 1
Private Sub Command1_Click()
ShellExecute 0&, "OPEN", "www.msn.com", vbNullString, "C:\", SW_SHOWNORMAL
' c:\ = Destination Folder
End Sub
sorry about that. I should have tried it first. I think there is a way to do it, but this works for sure.
-
Jan 22nd, 2005, 09:01 PM
#5
Hyperactive Member
Re: Help me please!!
nonono, he means like with the web browser control...
First goto Project > Components on the menu bar.
Scroll down until you find "Microsoft Internet Controls".
Check the box next to that one and click "Ok".
A picture of the world should appear in the control box on the left of VB (where you click to select a button, or label, etc).
Click the world and place the control onto the form.
Play around with the properties.
Hope that helps.
"I don't want to live alone until I'm married" - M.M.R.P
-
Jan 22nd, 2005, 09:23 PM
#6
Re: Help me please!!
that's a little bit more complicated than my first two suggestions, but if that is what you want, that's how to do it.
-
Jan 22nd, 2005, 11:39 PM
#7
Thread Starter
Lively Member
Re: Help me please!!
can u guys IM me on AIM, just so if i have any question because what u said was complicating with the checkbox and stuff...
aim lxhaxorxl
-
Jan 23rd, 2005, 12:21 AM
#8
Re: Help me please!!
I don't have aim. ms messenger
-
Jan 23rd, 2005, 03:48 AM
#9
Thread Starter
Lively Member
Re: Help me please!!
ok, nvm about AIM...
that idea with the MS Internet Controls thing worked for me, just how to i make it display my website?????
(im new to this remmeber!)
-
Jan 23rd, 2005, 04:06 AM
#10
Re: Help me please!!
first do a search on this forum for either webrowser control or inet control
and read all you can,
then start a simple project, adding the contorls you need and set the properties for the controls, then put in what ever code you can from what you have learned, cut and paste from the examples works great
then see if you can figure out why it isn't working.
then post here, with the code you are using and what your problem is
rgds pete
-
Jan 23rd, 2005, 06:13 AM
#11
Lively Member
Re: Help me please!!
On a blank form add a Text1 (textbox) and a WebBrowser1 (Web Browser control), then place this code in your form.
VB Code:
Private Sub Form_Resize()
'
Text1.Move 10, 0, Me.Width - 150
WebBrowser1.Move 10, Text1.Top + Text1.Height, Me.Width - 150, (Me.Height - WebBrowser1.Top)
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
'
If KeyAscii = vbKeyReturn Then
' see if ".com" is in the Text1.text field
If InStr(Text1.Text, ".com") Then
' if so then pass it to the WebBrowser1 control
WebBrowser1.Navigate Text1.Text
Else
' if not, toss it at the end of the google string
' and search google for the Text1.text
WebBrowser1.Navigate "http://www.google.com/search?q=" & Text1.Text
End If
KeyAscii = 0 ' clear KeyCode so you dont get a beep
' Comment out that line and you will hear a beep when the 'enter'
' is pressed.
End If
End Sub
That should get you started.
There is tons of info about this with-in the forum, search around and you will see.
_
~ What was once an opinion, became a fact, to be later proven wrong... ~
-
Jan 23rd, 2005, 11:23 PM
#12
Thread Starter
Lively Member
Re: Help me please!!
Hey that helped a lot!!!, now im wondering this one thing, how do i make it start of at a certain page when you open it?
like http://www.google.com how would i make that the homepage???
-
Jan 23rd, 2005, 11:29 PM
#13
Hyperactive Member
Re: Help me please!!
put the WebBrowser1.Navigate in the Form_Load event.
"I don't want to live alone until I'm married" - M.M.R.P
-
Jan 24th, 2005, 05:02 PM
#14
Thread Starter
Lively Member
-
Jan 24th, 2005, 05:37 PM
#15
Re: Help me please!!
open a form, press control-t to open components, click the checkbox next to M$ Internet Controls. This will add the world control. Double-click on it, and it will add a window to your form. This is where the web will open.
Then, add this to the form: (change the address if you want)
VB Code:
Option Explicit
Private Sub Form_Load()
WebBrowser1.Navigate "www.msn.com"
End Sub
-
Jan 24th, 2005, 07:44 PM
#16
Thread Starter
Lively Member
Re: Help me please!!
we need ppl like him thanks!! ill tell ya if it works...
-
Jan 24th, 2005, 07:53 PM
#17
Thread Starter
Lively Member
Re: Help me please!!
nice it workd!! hey, could you possibly help me make a browser?
-
Jan 24th, 2005, 08:18 PM
#18
Re: Help me please!!
I can help you when you get stuck, but i'm sure that if you search you can find the code to make a browser, but why not use IE?
-
Jan 24th, 2005, 09:38 PM
#19
Thread Starter
Lively Member
Re: Help me please!!
i just want my own browser to advertise my game im makin
-
Jan 24th, 2005, 09:50 PM
#20
Re: Help me please!!
a browser can't advertise anything. it is just a program to see pages on the internet. you woud need a web page, and a place to host it, and then usually some way to get people to see it, so that you could advertise.
-
Jan 24th, 2005, 10:22 PM
#21
Thread Starter
Lively Member
Re: Help me please!!
i kno i got a site, and with the browser i'd make it the homepage, so that way they have to see it when they open it, no matter what...
-
Jan 24th, 2005, 10:24 PM
#22
Re: Help me please!!
thats kind of..well annoying..
-
Jan 24th, 2005, 10:31 PM
#23
Re: Help me please!!
they already have those in IE. They are called BHO's, commonly known as Hijackers that take over your home page. You don't want to do this. Nobody would use a browser that they couldn't set the home page for.
You could set IE to your homepage, but only if the user wanted it.
ALSO: Take your personal information out of the first post. We can get it from your profile page. If you leave it here, the bots will get it and your domain and email will get spammed.
Last edited by dglienna; Jan 24th, 2005 at 10:35 PM.
-
Jan 24th, 2005, 11:31 PM
#24
Thread Starter
Lively Member
Re: Help me please!!
ack!!!! you guys dont understand...well
what i want is where you can set your homepage all everyhting like a normal browser, except it has a link to my site, so i can it hits, or something like that, but i want to make it so its like IE but, invisble it clicks a link, such as my website, giving me hits without them knowing it...
i think thats the best way to explain it
-
Jan 24th, 2005, 11:37 PM
#25
Re: Help me please!!
Doesn't sound like something that i'd want
-
Jan 24th, 2005, 11:38 PM
#26
Thread Starter
Lively Member
Re: Help me please!!
ok, heres the next thing, how do you make a window pop open when you click a link that is targeted for a new window, meaning when i click the link, it opens it inside my program, and not in IE...
-
Jan 24th, 2005, 11:39 PM
#27
Hyperactive Member
Re: Help me please!!
you could add an "ad bar" to the browser.
"I don't want to live alone until I'm married" - M.M.R.P
-
Jan 24th, 2005, 11:42 PM
#28
Thread Starter
Lively Member
-
Jan 25th, 2005, 12:01 AM
#29
Re: Help me please!!
i'm not sure. But, I found this:
http://www.vb-helper.com/howto_restricted_browser.html
this should give you an idea or two.
Last edited by dglienna; Jan 25th, 2005 at 12:05 AM.
-
Jan 25th, 2005, 12:23 AM
#30
Thread Starter
Lively Member
Re: Help me please!!
this just allows it to only go to one website, and stay there...only problem is, it stays at a blank website...and blocks EVERY WEBSITE that i try to go to on it...well check it out...
heres what i have so far, i have a TextBox Control, and the WebBrowser Control, and heres the code
VB Code:
Option Explicit
Private Sub Form_Load()
WebBrowser1.Navigate "STARTING PAGE"
End Sub
Private Sub Form_Resize()
'
Text1.Move 10, 0, Me.Width - 150
WebBrowser1.Move 10, Text1.Top + Text1.Height, Me.Width - 150, (Me.Height - WebBrowser1.Top)
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
'
If KeyAscii = vbKeyReturn Then
' see if ".com" is in the Text1.text field
If InStr(Text1.Text, ".com") Then
' if so then pass it to the WebBrowser1 control
WebBrowser1.Navigate Text1.Text
Else
' if not, toss it at the end of the google string
' and search google for the Text1.text
WebBrowser1.Navigate "http://www.google.com/search?q=" & Text1.Text
End If
KeyAscii = 0 ' clear KeyCode so you dont get a beep
' Comment out that line and you will hear a beep when the 'enter'
' is pressed.
End If
End Sub
Private Sub webBrowse_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
'txtURL.Text = URL 'Additionally you can use this, but it shows all child URL's too (such as URL's loaded in iFrames)
txtURL.Text = WebBrowser1.Document.URL
txtURL.SelStart = 0
txtURL.SelLength = Len(txtURL.Text)
End Sub
' Cancel any navigation that moves outside VB helper.
Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As _
Object, URL As Variant, Flags As Variant, _
TargetFrameName As Variant, PostData As Variant, _
Headers As Variant, Cancel As Boolean)
Const TARGET = "about:blank"""
Cancel = (LCase$(Left$(URL, Len(TARGET))) <> TARGET)
If Cancel Then MsgBox URL & " is blocked"
End Sub
' Don't let the user open a new window.
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel _
As Boolean)
Cancel = True
MsgBox "You cannot open a new window."
End Sub
EDIT: lets say i wanted to make it stay at http://www.google.com how would i do that?
-
Jan 25th, 2005, 12:58 AM
#31
Re: Help me please!!
I commented out the cancel=true, and got it to browse where I wanted.
you would just have it always navigate to the same page. if it didn't have the com, then it would do a google search
-
Jan 25th, 2005, 02:18 AM
#32
Member
Re: Help me please!!
Not to be mean or anything, but if you just started programming "a day ago" how exactly are you going to program a game? I've been programming in BASIC for 16 years and I can tell you there's nothing harder to make than a decent game!!!! Trust me..
-Mike
-
Jan 25th, 2005, 06:20 PM
#33
Thread Starter
Lively Member
Re: Help me please!!
ahh kk, cancel=true cancel that out...
________________________________
whatcha mean make a game, this is a web browser ....
-
Jan 25th, 2005, 06:32 PM
#34
Fanatic Member
Re: Help me please!!
If you want to read more about the Web Browser Control, read the articles in my signature. They provide in-depth information about the component, and also contain and example for a browser application.
Author for Visual Basic Web Magazine
-
Jan 26th, 2005, 12:09 AM
#35
Thread Starter
Lively Member
Re: Help me please!!
wow, nice!!!
ok so now theres a compile error in this part the error reads: "User-defined type not defined"
VB Code:
Private Sub tlbMain_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Key
Case "back"
webMain.GoBack
Case "forward"
webMain.GoForward
Case "stop"
webMain.Stop
Button.Enabled = False
Case "reload"
webMain.Refresh
Case "home"
webMain.GoHome
Case "search"
webMain.GoSearch
Case "preview"
webMain.ExecWB OLECMDID_PRINTPREVIEW, OLECMDEXECOPT_DODEFAULT
Case "print"
webMain.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DODEFAULT
Case "lock"
If Button.Value = tbrPressed Then
tlbMain.Buttons.Item("vbwm").Value = tbrUnpressed
Else
tlbMain.Buttons.Item("vbwm").Value = tbrUnpressed
End If
Case "vbwm"
If Button.Value = tbrPressed Then
tlbMain.Buttons.Item("lock").Value = tbrUnpressed
Else
tlbMain.Buttons.Item("lock").Value = tbrUnpressed
End If
End Select
End Sub
i kinda know what it means, but not completely....
-
Jan 26th, 2005, 12:12 AM
#36
-
Jan 26th, 2005, 01:11 AM
#37
Thread Starter
Lively Member
Re: Help me please!!
VB Code:
Private Sub tlbMain_ButtonClick(ByVal Button As MSComctlLib.Button)
thats the line thats crashing...i think its because..well nvm, ill let you answer it...
-
Jan 26th, 2005, 01:14 AM
#38
Re: Help me please!!
did you add the component Common Control?
-
Jan 26th, 2005, 01:51 AM
#39
Thread Starter
Lively Member
-
Jan 26th, 2005, 02:11 AM
#40
Re: Help me please!!
Found it for you. I guess you didn't download the sample project from the article? You should. It has everything you need for the basics.
Last edited by dglienna; Jan 26th, 2005 at 02:19 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|