PC Review


Reply
Thread Tools Rate Thread

Detailed info for COM based "Web Browser" control in VS.NET 2003

 
 
Ahmed Shafi
Guest
Posts: n/a
 
      16th Mar 2005
Hi there,

Can some one point me toward detailed tutorials / resources as to how to use
the COM based web browser control (not the manged WebBroser Control in C#
2.0) in wnforms ? How to access the contents of the page that is being
visited by the user ? is there any sample code that shows how to do this ?
is there a managed component made by some one which encapsulates the COM web
browser component and can be used in v 1.1 ?

Thanks.


 
Reply With Quote
 
 
 
 
Grant_Aust
Guest
Posts: n/a
 
      17th Mar 2005
Hi Ahmed,
I have been looking into this for the last few days. It's ot so easy to
work with an embedded browser due to the lack of informaiont.

You need to add a reference to MSHTML.dll to your project.

See here for info about mshtml.dll;
http://msdn.microsoft.com/workshop/b...w/overview.asp

The diagram here helps for understanding;
http://msdn.microsoft.com/workshop/b...w/overview.asp

Do a search on google for webbrowser and mshtml and the like and you will
find some info.

I am still working through this stuff now.

Here are some code scraps I have found;

' This sample handler code for the WebBrowser
DWebBrowserEvents2:ocumentComplete event
'demonstrates how to determine if this event is for the top frame, which
indicates that the
'HTML page has loaded. This sample also demonstrates how to create a
stream from a block of
'memory-in this case a string that contains the HTML content to be
displayed.
'void myObject:ocumentComplete(LPDISPATCH pDisp, VARIANT* URL)
'{
' HRESULT hr;
' IUnknown* pUnkBrowser = NULL;
' IUnknown* pUnkDisp = NULL;
' IStream* pStream = NULL;
' HGLOBAL hHTMLText;
' static TCHAR szHTMLText[] = "<html><h1>Stream Test</h1><p>This HTML
content is/
' being loaded from a stream.</html>";

' // Is this the DocumentComplete event for the top frame window?
' // Check COM identity: compare IUnknown interface pointers.
' hr = m_pBrowser->QueryInterface( IID_IUnknown,
(void**)&pUnkBrowser );
' if ( SUCCEEDED(hr) )
' {
' hr = pDisp->QueryInterface( IID_IUnknown, (void**)&pUnkDisp );
' if ( SUCCEEDED(hr) )
' {
' if ( pUnkBrowser == pUnkDisp )
' { // This is the DocumentComplete event for the top
' // frame - page is loaded!
' // Create a stream containing the HTML.
' // Alternatively, this stream may have been passed to
us.

' size_t = cchLength;
' // TODO: Safely determine the length of szHTMLText in
TCHAR.
' hHTMLText = GlobalAlloc( GPTR, cchLength+1 );

' if ( hHTMLText )
' {
' size_t cchMax = 256;
' StringCchCopy((TCHAR*)hHTMLText, cchMax + 1,
szHTMLText);
' // TODO: Add error handling code here.

' hr = CreateStreamOnHGlobal( hHTMLText, TRUE,
&pStream );
' if ( SUCCEEDED(hr) )
' {
' // Call the helper function to load the browser
from the stream.
' LoadWebBrowserFromStream( m_pBrowser,
Stream );
' pStream->Release();
' }
' GlobalFree( hHTMLText );
' }
' }
' pUnkDisp->Release();
' }
' pUnkBrowser->Release();
' }
'}

' An application would show the progress bar in response to
DownloadBegin,
'update the progress bar in response to ProgressChange, and hide the
progress bar
'in response to DownloadComplete.

'Dim hDoc As New mshtml.HTMLDocument
'Do
' hDoc = WebBrowser1.Document()
'Loop While hDoc Is Nothing
'hDoc.getElementsByTagName("a").item(2).Click()



 
Reply With Quote
 
Grant_Aust
Guest
Posts: n/a
 
      17th Mar 2005
Ahmed,
Let me know what you find out and I will keep you posted also.

My personal e-mail address is;

news
at
carthew
..
net


 
Reply With Quote
 
Peter Huang [MSFT]
Guest
Posts: n/a
 
      17th Mar 2005
Hi

There is not such a dedicated C# version webbrowser course.
Anyway, since so far we still use the com based webbrowser(managed one will
be released in whidbey), so it's object modal and interface is the same as
the C++ ones.

IWebBrowser2 Interface
http://msdn.microsoft.com/library/de...owser/webbrows
er/reference/ifaces/iwebbrowser2/iwebbrowser2.asp

WebBrowser Control
http://msdn.microsoft.com/library/de...owser/webbrows
er/reference/ifaces/iwebbrowser2/iwebbrowser2.asp

To manipulate the document inside the webbrowser, we need the mshtml
library which has a managed wrap in the .NET(microsoft.mshtml.dll)
MSHTML Reference
http://msdn.microsoft.com/library/de...owser/webbrows
er/reference/ifaces/iwebbrowser2/iwebbrowser2.asp

Here are a few links for your reference.

How To Get Width and Height from the Window.Open Method Inside the
WebBrowser Host by Using Visual C# .NET (313966)
http://support.microsoft.com/default...B;EN-US;313966

Multi Tab WebBrowser
http://www.codeproject.com/useritems...WebBrowser.asp


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"microsoft web browser" control in Access 2003: setting default font Spencer Steel Microsoft Access Form Coding 0 25th Jun 2008 04:45 PM
JavaScript "TextBox.Select()" function problem with new .NET 2.0 browser control subbarao.puvvada@gmail.com Microsoft VB .NET 1 29th May 2007 07:35 AM
"ASP.NET 2005 custon server control" in "ASP.NET 2003 application" Electric Co. Microsoft ASP .NET 1 10th Oct 2006 03:47 AM
Avast "Show detailed info" suggestion/problem Lars-Erik Østerud Anti-Virus 0 15th Mar 2006 02:44 PM
supressing the "would you like to open the file or save..." message from web browser control Jerry Shea Microsoft Dot NET Framework Forms 4 10th Mar 2004 11:35 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:36 AM.