|
-
Oct 1st, 2000, 11:39 AM
#1
Thread Starter
New Member
Hello.
I am writing a ActiveX Control File (VB) which will be packaged as *.CAB
In this ActiveX Control, I would like to have a button which can open a new Browser with URL.
How can I do that?
The simple question is: How can I call a URL with new browser in ActiveX Control (VB) ?
-
Oct 1st, 2000, 05:09 PM
#2
It's easy.
Add the following code:
Code:
Dim ies As New InternetExplorer
ies.Navigate2 Text1
And it will open a new IE window and navigats to the url that the text1 specifies.
Don't forget to add "Microsoft Internet Controls" to your references section .
-
Oct 1st, 2000, 08:00 PM
#3
That works fine if you assume the end user has and uses Internet Explorer, otherwise you can instantiate the default registered browser using the ShellExecute API, i.e.
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 Sub Command1_Click()
ShellExecute 0, "OPEN", "http:\\www.vb-world.net", "", "", 1
End Sub
If IE is already open this will usually use the Open browser, if you definitely always want to open a new browser window do something like this:
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 Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As String) As Long
Private Sub Command1_Click()
Dim sEXE As String
sEXE = FindBrowserEXE
If Len(sEXE) Then
ShellExecute 0, "OPEN", sEXE, "http:\\www.vb-world.net", "", 1
End If
End Sub
Function FindBrowserEXE() As String
Dim sPath As String
Dim iFile As Integer
sPath = Space(255)
iFile = FreeFile
Open "C:\Temp.htm" For Output As iFile
Close iFile
FindBrowserEXE = Left(sPath, FindExecutable("C:\Temp.htm", "", ByVal sPath))
Kill "C:\Temp.htm"
End Function
-
Oct 1st, 2000, 08:30 PM
#4
Thread Starter
New Member
Thank you Escaflowne and Aaron Young.
But how can I specific the target frame if I want to change the URL in other frame ?
-
Oct 2nd, 2000, 12:12 PM
#5
Thread Starter
New Member
Also, one more question.
In ActiveX Control, can I call Javascript object in the same page?
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
|