469,590 Members | 2,500 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,590 developers. It's quick & easy.

WebBrowser / My.Resources question

Can I call a file (*.html) within My.Resources to show-up in my
WebBrowser control? If so, please provide a sample code or a link.
Thanks in advance for your help.

William Cruz

*** Sent via Developersdex http://www.developersdex.com ***
Mar 28 '07 #1
3 3898
This is what I am doing and it gives me an error:

WebBrowser1.Navigate(My.Resources.Software_License _Agreement)
Error:
"Error HRESULT E_FAIL has been returned from a call to a COM component."
William

*** Sent via Developersdex http://www.developersdex.com ***
Mar 28 '07 #2
You should load the HTML content directly into the webbrowser and not trying
to load from a location.

Here is a code to load dynamicaly the HTML into the webbrowser (You will
have to change the PageForText to your control name or if this code is
within the browser itself, Me).

Private Sub LoadContent(ByVal HTML As String)
' ensure that the document is loaded, otherwise the next line
fails...
If PageForText.Document Is Nothing Then
PageForText.Navigate2("about:blank")
' get a reference to the document...
Dim clsDocument As mshtml.HTMLDocument = CType(PageForText.Document,
mshtml.HTMLDocument)
' initiailize the document using the IPersistStreamInit COM
interface...
DirectCast(clsDocument, IPersistStreamInit).InitNew()
' Marshal the content into a interop stream...
Dim ptrValue As IntPtr =
System.Runtime.InteropServices.Marshal.StringToHGl obalAuto(HTML)
Dim clsStream As System.Runtime.InteropServices.UCOMIStream =
Nothing
CreateStreamOnHGlobal(ptrValue, True, clsStream)
' load the content into the browser..
DirectCast(clsDocument, IPersistStreamInit).Load(clsStream)
End Sub
Jonathan Boivin
---
jo************@cints.net | http://www.cints.net
"William Cruz" <wc*****@msn.coma écrit dans le message de news:
On**************@TK2MSFTNGP03.phx.gbl...
This is what I am doing and it gives me an error:

WebBrowser1.Navigate(My.Resources.Software_License _Agreement)
Error:
"Error HRESULT E_FAIL has been returned from a call to a COM component."
William

*** Sent via Developersdex http://www.developersdex.com ***

Mar 28 '07 #3
You will need these too .. (Let me know if something is missing)

Public Enum HRESULT
S_OK = 0
S_FALSE = 1
E_NOTIMPL = &H80004001
E_INVALIDARG = &H80070057
E_NOINTERFACE = &H80004002
E_FAIL = &H80004005
E_UNEXPECTED = &H8000FFFF
End Enum

<ComVisible(True), ComImport(),
Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"),
InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIUnknown)_
Public Interface IPersistStreamInit : Inherits IPersist
Shadows Sub GetClassID(ByRef pClassID As Guid)
<PreserveSig()Function IsDirty() As Integer
<PreserveSig()Function Load(ByVal pstm As UCOMIStream) As HRESULT
<PreserveSig()Function Save(ByVal pstm As UCOMIStream,
<MarshalAs(UnmanagedType.Bool)ByVal fClearDirty As Boolean) As HRESULT
<PreserveSig()Function GetSizeMax(<InAttribute(), Out(), _
MarshalAs(UnmanagedType.U8)ByRef pcbSize As Long) As HRESULT
<PreserveSig()Function InitNew() As HRESULT
End Interface

<ComVisible(True), ComImport(),
Guid("0000010c-0000-0000-C000-000000000046"),
InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIUnknown)_
Public Interface IPersist
Sub GetClassID(ByRef pClassID As Guid)
End Interface

Declare Function CreateStreamOnHGlobal Lib "ole32" (ByVal hGlobal As
IntPtr, ByVal fDeleteOnRelease As Boolean, ByRef ppstm As UCOMIStream) As
Long
Jonathan Boivin
---
jo************@cints.net | http://www.cints.net
"William Cruz" <wc*****@msn.coma écrit dans le message de news:
eh*************@TK2MSFTNGP04.phx.gbl...
Can I call a file (*.html) within My.Resources to show-up in my
WebBrowser control? If so, please provide a sample code or a link.
Thanks in advance for your help.

William Cruz

*** Sent via Developersdex http://www.developersdex.com ***

Mar 28 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by ASP .NET Newbie | last post: by
19 posts views Thread by Blair P. Houghton | last post: by
reply views Thread by Andy Bates | last post: by
1 post views Thread by alexander.stuckenholz | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.