473,624 Members | 2,264 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using AxWebBrowser in VB 2005

Doe
Okay, I've given up on using the "new" WebBrowser in 2005 to do what I
want to do -- tabbed browsing. It seems I really need RegisterAsBrows er
and Application to get each instance of a browser working on each tab
(and those methods are not available in 2005).

I found some code on MSDN forums, but the extention didn't really cover
RegisterAsBrows er. Someone told me how to do it, but it's in c and
basically over my head. Even though he later added some VB code (<In>
should be changed to <[In]>). I would need definitions for each
OLECMD... and I couldn't figure out what to attach the interfaces to...

http://forums.microsoft.com/MSDN/Sho...83565&SiteID=1...
Sigh. So I figured, okay, this is a LOT OF TROUBLE just to make the
"new" browser work like the "old" browser. So I'll just USE the "old"
AxWebBrowser in 2005. Solves all my problems, code will work, will have
RegisterAsBrows er. (Yes, someone on this group told me the browsers are
basically the same just "wrapped" differently.)

Dim ThisBrowser as New SHDocVw.AxWebBr owser

Only I can't declare a new browser as AxWebBrowser. I get an error of
AxWebBrowser ambigious in ShowDocVw namespace.

I have references to both Interop.SHDocVw and AxInerop.SHDocV w in my
project. But when I go into the form to do an Import, all I get is the
SHDocVw namespace with no ability to add on dots and sub namespaces.

What am I doing wrong? How can I do the right Imports and namespaces?
How can I declare a new instance of an AxWebBrowser?

This namespace stuff makes my head swim, actually. I am a fairly good
programmer, but some of this VB.Net stuff is too convoluted.

Any help appreciated as I stumble around in the dark.

Doe

Mar 16 '06 #1
7 6784
> Okay, I've given up on using the "new" WebBrowser in 2005 to do what I
want to do -- tabbed browsing. It seems I really need RegisterAsBrows er
and Application to get each instance of a browser working on each tab
(and those methods are not available in 2005).


I would recommend you try the 2005 WB again. What you're trying to do
should pretty straight forward:

Dim wb As IWebBrowser2 = DirectCast(Me.W ebBrowser1.Acti veXInstance,
IWebBrowser2)
wb.RegisterAsBr owser = True

The slightly tricky part would be defining IWebBrowser2... just do a search
on http://www.pinvoke.net/ and then just copy and paste. You will need to
get the definitions to the following:

IWebBrowser2
OLECMDID
OLECMDEXCOPT
OLECMDF
tagREADYSTATE

--
Colin Neller
http://www.colinneller.com/blog
Mar 16 '06 #2
CMM
Hopefully this will get you started... my nice little webbrowser inherited
from VS2005's webbrowser to add missing functionality. You need to add a
reference to Microsoft Internet Controls COM object.

Imports System.Runtime. InteropServices

<StructLayout(L ayoutKind.Seque ntial)> _
Friend Structure OLECMDTEXT
Public cmdtextf As UInt32
Public cwActual As UInt32
Public cwBuf As UInt32
Public rgwz As Char
End Structure

<StructLayout(L ayoutKind.Seque ntial)> _
Friend Structure OLECMD
Public cmdID As Long
Public cmdf As UInt64
End Structure

' Interop definition for IOleCommandTarg et.
<ComImport(), Guid("b722bccb-4e68-101b-a2bc-00aa00404770"),
InterfaceType(C omInterfaceType .InterfaceIsIUn known)> _
Friend Interface IOleCommandTarg et
' IMPORTANT: The order of the methods is critical here. We're going to
' perform early binding in most cases, so the order of the methods
' here MUST match the order of their vtable layout (which is determined
' by their layout in IDL). The interop calls key off the vtable
ordering,
' not the symbolic names, so if you switched these method declarations
' and attempted to call Exec() on an IOleCommandTarg et interface from
your
' app, it would translate into a call to QueryStatus() instead.
Sub QueryStatus(ByR ef pguidCmdGroup As Guid, ByVal cCmds As UInt32,
<MarshalAs(Unma nagedType.LPArr ay, SizeParamIndex: =1)> ByVal prgCmds As
OLECMD, ByRef pCmdText As OLECMDTEXT)
Sub Exec(ByRef pguidCmdGroup As Guid, ByVal nCmdId As Long, ByVal
nCmdExecOpt As Long, ByRef pvaIn As Object, ByRef pvaOut As Object)
End Interface

''' <summary>
''' Inherited from .NET 2.0 Webbrowser to provide missing functionality.
''' </summary>
''' <remarks>Even the new .NET 2.0 Webbrowser doesn't implement a full
feature set... this class begins to solve that.</remarks>
Public Class EnhancedWebBrow ser
Inherits WebBrowser

Private commandGuid As New Guid(&HED016940 , -17061, &H11CF, &HBA, &H4E,
&H0, &HC0, &H4F, &HD7, &H8, &H16)

Private Enum MiscCommandTarg et
Find = 1
ViewSource = 2
End Enum

Private ReadOnly Property UnderlyingBrows er() As SHDocVw.WebBrow ser

Get
Return CType(Me.Active XInstance, SHDocVw.WebBrow ser)
End Get

End Property

Public Function IsEditCutEnable d() As Boolean

Dim result As SHDocVw.OLECMDF =
Me.UnderlyingBr owser.QueryStat usWB(SHDocVw.OL ECMDID.OLECMDID _CUT)

Return ((result And SHDocVw.OLECMDF .OLECMDF_ENABLE D) =
SHDocVw.OLECMDF .OLECMDF_ENABLE D)

End Function

Public Function IsEditCopyEnabl ed() As Boolean

Dim result As SHDocVw.OLECMDF =
Me.UnderlyingBr owser.QueryStat usWB(SHDocVw.OL ECMDID.OLECMDID _COPY)

Return ((result And SHDocVw.OLECMDF .OLECMDF_ENABLE D) =
SHDocVw.OLECMDF .OLECMDF_ENABLE D)

End Function

Public Function IsEditPasteEnab led() As Boolean

Dim result As SHDocVw.OLECMDF =
Me.UnderlyingBr owser.QueryStat usWB(SHDocVw.OL ECMDID.OLECMDID _PASTE)

Return ((result And SHDocVw.OLECMDF .OLECMDF_ENABLE D) =
SHDocVw.OLECMDF .OLECMDF_ENABLE D)

End Function

Public Function IsEditUndoEnabl ed() As Boolean

Dim result As SHDocVw.OLECMDF =
Me.UnderlyingBr owser.QueryStat usWB(SHDocVw.OL ECMDID.OLECMDID _UNDO)

Return ((result And SHDocVw.OLECMDF .OLECMDF_ENABLE D) =
SHDocVw.OLECMDF .OLECMDF_ENABLE D)

End Function

Public Sub ExecEditCut()

Me.UnderlyingBr owser.ExecWB(SH DocVw.OLECMDID. OLECMDID_CUT,
SHDocVw.OLECMDE XECOPT.OLECMDEX ECOPT_DONTPROMP TUSER)

End Sub

Public Sub ExecEditCopy()

Me.UnderlyingBr owser.ExecWB(SH DocVw.OLECMDID. OLECMDID_COPY,
SHDocVw.OLECMDE XECOPT.OLECMDEX ECOPT_DONTPROMP TUSER)

End Sub

Public Sub ExecEditPaste()

Me.UnderlyingBr owser.ExecWB(SH DocVw.OLECMDID. OLECMDID_PASTE,
SHDocVw.OLECMDE XECOPT.OLECMDEX ECOPT_DONTPROMP TUSER)

End Sub

Public Sub ExecEditUndo()

Me.UnderlyingBr owser.ExecWB(SH DocVw.OLECMDID. OLECMDID_UNDO,
SHDocVw.OLECMDE XECOPT.OLECMDEX ECOPT_DONTPROMP TUSER)

End Sub

Private Sub ExecOleCommandT arget(ByVal command As MiscCommandTarg et)

Dim commandTarget As IOleCommandTarg et
Dim obj As Object

Try
commandTarget = CType(Me.Docume nt.DomDocument,
IOleCommandTarg et)
commandTarget.E xec(commandGuid , command,
SHDocVw.OLECMDE XECOPT.OLECMDEX ECOPT_DODEFAULT , obj, obj)
Catch
Throw (New Exception(Err.G etException().M essage))
End Try

End Sub

Public Sub ShowFindDialog( )

ExecOleCommandT arget(MiscComma ndTarget.Find)

End Sub

Public Sub ShowSource()

ExecOleCommandT arget(MiscComma ndTarget.ViewSo urce)

End Sub

End Class

--
-C. Moya
www.cmoya.com
"Colin Neller" <cn*****@gmail. com> wrote in message
news:Oo******** ******@TK2MSFTN GP09.phx.gbl...
Okay, I've given up on using the "new" WebBrowser in 2005 to do what I
want to do -- tabbed browsing. It seems I really need RegisterAsBrows er
and Application to get each instance of a browser working on each tab
(and those methods are not available in 2005).


I would recommend you try the 2005 WB again. What you're trying to do
should pretty straight forward:

Dim wb As IWebBrowser2 = DirectCast(Me.W ebBrowser1.Acti veXInstance,
IWebBrowser2)
wb.RegisterAsBr owser = True

The slightly tricky part would be defining IWebBrowser2... just do a
search on http://www.pinvoke.net/ and then just copy and paste. You will
need to get the definitions to the following:

IWebBrowser2
OLECMDID
OLECMDEXCOPT
OLECMDF
tagREADYSTATE

--
Colin Neller
http://www.colinneller.com/blog

Mar 17 '06 #3
Doe
Thanks, Colin, I was wondering if a Direct Cast was possible. I have
found code for IWebBrowser2.

Thanks, C. Moya. Very nice, but I already have code for stuff like Find
and Copy/Paste in both 2003 and 2005. Need the RegisterAsBrows er. And
have already found those definitions for OLECMDTEXT and OLECMD. Need
the others that Colin mentioned.

Thanks for the replies, guys. Going to try Colin's suggest and see if
it works. Will report back. A Direct Cast just might do it.

Later, Doe

Mar 17 '06 #4
CMM
You should have looked more closely. From within the inherited "extended"
WebBrowser class I posted...

Me.UnderlyingBr owser.RegisterA sBrowser = True

The code for "UnderlyingBrow ser" is simply:

Public ReadOnly Property UnderlyingBrows er() As SHDocVw.WebBrow ser

Get
Return CType(Me.Active XInstance, SHDocVw.WebBrow ser)
End Get

End Property
--
-C. Moya
www.cmoya.com
"Doe" <do*******@aol. com> wrote in message
news:11******** **************@ u72g2000cwu.goo glegroups.com.. .
Thanks, Colin, I was wondering if a Direct Cast was possible. I have
found code for IWebBrowser2.

Thanks, C. Moya. Very nice, but I already have code for stuff like Find
and Copy/Paste in both 2003 and 2005. Need the RegisterAsBrows er. And
have already found those definitions for OLECMDTEXT and OLECMD. Need
the others that Colin mentioned.

Thanks for the replies, guys. Going to try Colin's suggest and see if
it works. Will report back. A Direct Cast just might do it.

Later, Doe

Mar 17 '06 #5
Doe
Cool.

Doe

Mar 17 '06 #6
CMM
Clarification to previous post (read it first):
Actually I made UnderlyingBrows er private to the class... you can easily
make it public and expose it or make a new wrapper property for
RegisterAsBrows er as so:

Public Property RegisterAsBrows er() As Boolean
Get
Return Me.UnderlyingBr owser.RegisterA sBrowser
End Get
Set(ByVal value As Boolean)
Me.UnderlyingBr owser.RegisterA sBrowser = value
End Set
End Property
--
-C. Moya
www.cmoya.com
"CMM" <cm*@nospam.com > wrote in message
news:OF******** ******@TK2MSFTN GP09.phx.gbl...
You should have looked more closely. From within the inherited "extended"
WebBrowser class I posted...

Me.UnderlyingBr owser.RegisterA sBrowser = True

The code for "UnderlyingBrow ser" is simply:

Public ReadOnly Property UnderlyingBrows er() As SHDocVw.WebBrow ser

Get
Return CType(Me.Active XInstance, SHDocVw.WebBrow ser)
End Get

End Property
--
-C. Moya
www.cmoya.com
"Doe" <do*******@aol. com> wrote in message
news:11******** **************@ u72g2000cwu.goo glegroups.com.. .
Thanks, Colin, I was wondering if a Direct Cast was possible. I have
found code for IWebBrowser2.

Thanks, C. Moya. Very nice, but I already have code for stuff like Find
and Copy/Paste in both 2003 and 2005. Need the RegisterAsBrows er. And
have already found those definitions for OLECMDTEXT and OLECMD. Need
the others that Colin mentioned.

Thanks for the replies, guys. Going to try Colin's suggest and see if
it works. Will report back. A Direct Cast just might do it.

Later, Doe


Mar 17 '06 #7
Doe
Okay, there is something I am not understanding here. I finally got
around to testing this. When I try it, calling RegisterAsBrows er, I get
an error message -- must use new keyword.

I am doing:
Dim ThisBrowser As EnhancedWebBrow ser

ThisBrowser = New EnhancedWebBrow ser
ThisBrowser.Und erlyingBrowser. RegisterAsBrows er = True

But somehow there must also be a New required for the Underlying
Browser, to create a new instance.

Right? Should that be put in the Class, Public Sub New?

Sigh. Sorry to be such a dunce.

Doe

Mar 27 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5083
by: antoine Veret | last post by:
Hi, is there changes on axWebBrowser with framework 1.1 ? events doesn't fire for this object. and an other question; how release memory for axWebBrowser object ? when i create those objects, iexplorer.exe grow up and do not reduce in size when i call the dispose method of my object. -- ZeD -------------- Epita promo 2005 zed@3ie.org ---- icq : 163250811
0
2907
by: Matthias Kwiedor | last post by:
I have a aplication which hosts an axWebbrowser. This activex component needs about 10 to 15 mb of memory. Because i have a option to move the aplication to tray icon and do some timer work i don't want that it just spends over 10mb for nothing. So i remove the axwebbrowser with axwebbrowser1.dispose() which works fine. After show the application back from the tray icon i will implement the axwebbrowser again with the same i did it...
1
1765
by: Les Caudle | last post by:
I created an app that uses an axWebBrowser control to display a local xml file and had no problems. When the form is initially loaded, it displays an htm file that says no file is loaded: object o = System.Reflection.Missing.Value; axWebBrowser1.Navigate(@"file:///" + ((string)(Application.StartupPath + @"\noXml.htm")).Replace(@"\",@"/"), ref o, ref o, ref o, ref o);
0
1585
by: beau | last post by:
Hi, I'm using the AxWebBrowser in a C# WinForms application. I've got the basics working, but need some help controlling the view options for browsing files. How can I disable the "WebView"/Tasks pane on the left side of the file view? I've looked around and know it can be done globally from the registry
0
2046
by: sagar.jawale | last post by:
Hi, In my c# windows application, i am using AxSHDocVw.AxWebBrowser. I am displaying a generated receipt html in this browser. Also, for printing the same html, i am using the following command : axWebBrowser2.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER,ref empty,ref empty);
6
3762
by: Dave Booker | last post by:
It appears that I cannot correctly install the AxWebBrowser in VS2005. I can instantiate an "AxWebBrowser browser" and refer to its members, properties, and methods. I'm having trouble with the AxWebBrowser.Document: When I print browser.Document.GetType().ToString() at runtime, I get "mshtml.HTMLDocumentClass". But The VS2005 compiler does not recognize the member AxWebBrowser.Document as anything other than a System.Object -- e.g.,...
4
1434
by: =?Utf-8?B?RGF2ZSBF?= | last post by:
I have written an application that reads third party web pages. If I am using HTTP everything works fine. I create an AxSHDocVw.AxWebBrowser object and then Navigate2 to the page. I then populate some form fields, browse to the appropriate button on the page and then call it's click method. This works just fine using HTTP. However, one of the web pages changed to HTTPS (actually 2 of them have). Now, the click does not throw an...
2
2109
by: Michael | last post by:
Hi experts, I am using axWebBrowser in windows form to load web pages. There is a page that contains a group of buttons. (More than 10 buttons.) The source code behind each button is like below: <input type="submit" name="Submit" value="Submit" onClick="afm.__act.value=' SITE.9.20081206A__id.30.AdminsSelected.adp.actRegister';return SubmitOnlyOnce();">
1
1351
by: tim2006 | last post by:
When i try to run the program, it just hangs. If i remove the axwebbrowser control it works fine. Any ideas? Here is my code: class1.vb Imports System.Windows.Forms Imports System.Threading
0
8233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8170
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8474
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7158
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6108
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5561
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2604
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1784
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.