Costellot
asked on
Calling Firefox MozillaBrowser from Visual Basic VB6
Hi,
I have a VB app that currently user IE InternetExplorer Browser which is call using the following commands.
Dim obj As InternetExplorer
Set obj = New InternetExplorer
I'm trying to use MozillaBrowser but it doesn't work in ny app the way that IE does. ere is what I have tried.
Dim obj As MozillaBrowser
Set obj = New MozillaBrowser
or
Set obj = New MOZILLACONTROLLib.MozillaB rowser
Please help.
Thanks
Tom
I have a VB app that currently user IE InternetExplorer Browser which is call using the following commands.
Dim obj As InternetExplorer
Set obj = New InternetExplorer
I'm trying to use MozillaBrowser but it doesn't work in ny app the way that IE does. ere is what I have tried.
Dim obj As MozillaBrowser
Set obj = New MozillaBrowser
or
Set obj = New MOZILLACONTROLLib.MozillaB
Please help.
Thanks
Tom
If you have mozzila installed on your computer you can set the a string in the registry and set mozzila to be default and then set it back to IE when your finsished.
HKEY_CLASSES_ROOT\http\she ll\open\co mmand
default "C:\Program Files\Internet Explorer\iexplore.exe" -nohome
You then just change the path to point the mozzila webbrowser location
'Registry code...
Option Explicit
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Const HKEY_CLASSES_ROOT = &H80000000
Private Const HKEY_CURRENT_CONFIG = &H80000005
Private Const HKEY_CURRENT_USER = &H80000001
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const HKEY_USERS = &H80000003
Private Const ERROR_SUCCESS = 0&
Private Const REG_SZ = 1
Private Const REG_DWORD = 4
Private Sub SaveString(hKey As Long, strPath As String, strValue As String, strData As String)
Dim keyhand As Long
Dim X As Long
Dim r As Long
X = RegCreateKey(hKey, strPath, keyhand)
X = RegSetValueEx(keyhand, strValue, 0, REG_SZ, ByVal strData, Len(strData))
X = RegCloseKey(keyhand)
End Sub
Private Sub Command1_Click()
'set IE to default browser
Call SaveString(HKEY_CLASSES_RO OT, "http\shell\open\command", "", "C:\Program Files\Internet Explorer\iexplore.exe") ' string value
End Sub
Private Sub Command2_Click()
'set Mozilla to default browser
Call SaveString(HKEY_CLASSES_RO OT, "http\shell\open\command", "", "C:\Program Files\Mozilla\firefox.exe" ) ' string value
End Sub
HKEY_CLASSES_ROOT\http\she
default "C:\Program Files\Internet Explorer\iexplore.exe" -nohome
You then just change the path to point the mozzila webbrowser location
'Registry code...
Option Explicit
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Const HKEY_CLASSES_ROOT = &H80000000
Private Const HKEY_CURRENT_CONFIG = &H80000005
Private Const HKEY_CURRENT_USER = &H80000001
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const HKEY_USERS = &H80000003
Private Const ERROR_SUCCESS = 0&
Private Const REG_SZ = 1
Private Const REG_DWORD = 4
Private Sub SaveString(hKey As Long, strPath As String, strValue As String, strData As String)
Dim keyhand As Long
Dim X As Long
Dim r As Long
X = RegCreateKey(hKey, strPath, keyhand)
X = RegSetValueEx(keyhand, strValue, 0, REG_SZ, ByVal strData, Len(strData))
X = RegCloseKey(keyhand)
End Sub
Private Sub Command1_Click()
'set IE to default browser
Call SaveString(HKEY_CLASSES_RO
End Sub
Private Sub Command2_Click()
'set Mozilla to default browser
Call SaveString(HKEY_CLASSES_RO
End Sub
If you're just looking to open a page in Firefox, all you have to do is this:
Place this in a module / form:
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
Place this where you want to use it:
lRet = ShellExecute(Me.hwnd, "open", "C:\Program Files\mozilla\firefox\fire fox.exe", "http://www.userisms.com", vbNullString, 1)
You'll have to change the path to mozilla, I am not sure if I have typed it correctly.
Place this in a module / form:
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
Place this where you want to use it:
lRet = ShellExecute(Me.hwnd, "open", "C:\Program Files\mozilla\firefox\fire
You'll have to change the path to mozilla, I am not sure if I have typed it correctly.
ASKER
Thanks for all of your feedback.
Does anyone konw how to obtin the Document Object Model of a Firefox web page page once it has been loaded in the browser?
Thanks,
Tom
Does anyone konw how to obtin the Document Object Model of a Firefox web page page once it has been loaded in the browser?
Thanks,
Tom
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.iol.ie/~locka/mozilla/control.htm