USING IE WITHIN A Windows Forms Application

xiaoxiao2021-03-06  67

USING IE WITHIN A Windows Forms Application

Changed this blog Posting Into an article. It's job, And might be Handy to Keep Around ...

Everytime I'm busy with something I think: hmmm, Would Be nice to shared this .. but one war 'ot 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 \

I'm working on a simple windows forms app to browse some of the hierarchies of SharePoint Portal Server 2003, and besides a tree control on the left side I needed a browser control at the right side to display some detail information in HTML. Of course you can add the Internet Explorer dll shdocvw.dll to the toolbox so a wrapper is generated ... but there are some problems left like what values ​​to pass for all those parameters and how do I handle events that are raised.

One of the .Net world famous programmers Lutz Roeder, developer of Reflector (http://www.aisto.com/roeder/dotnet) did write a class encapsulating the Internet Explorer Active-X control that is used in Reflector. Although he did NOT Publish The Source Code (As Far As I Know), this File Came on The Web One Way or the Other. i Found It At The Following Link:

http://groups.google.com/groups?hl=en&lr=uE=utf-8&oE=UTF-8 &SELM=#$87PZ4PBHA.1860@tkmsftngp04&rnum=8

The Code Follows Below, TOGETHER with SOME CODE How To Use it ....

// Lutz Roeders's .NET Reflector, October 2000.

// CopyRight (C) 2000-2002 Lutz Roeder. All Rights Reserved.

// http://www.aisto.com/rxxxx/dotnet

// rxxxxx@aisto.com

Namespace Reflector.library

{

Using system;

Using system.io;

Using system.Runtime.InteropServices;

Using system.windows.forms;

Public Class Htmlbrowser: Axhost, IWebBBROWSEREVENTS

{

Public Event BrowsernaVigate; Public Event Browsernavigate;

IWebBrowser Control = NULL;

ConnectionPointCookie cookie;

Boolean Activate = FALSE;

String Url = string.empty;

String html = string.empty;

String body = string.empty;

Public HTMLBROWSER (): BASE ("8856F961-340A-11D0-A96B-00C04FD705A2")

{

Handlecreated = New EventHandler (me_handlecreated);

NavigateComplete = New BrowsernavigateEventHandler (me_navigateComplete);

}

Public void activate ()

{

Activate = true;

}

Public void navigate (String URL)

{

IF (! ishandlecreated)

{

this.url = URL;

Return;

}

Object flags = 0;

Object targetframe = string.empty;

Object poster = string.empty;

Object headers = String.empty;

Control.naviGate (URL, Ref Flags, Ref TargetFrame, Ref PostData, REF

Headers);

}

Public void sethtmltext (String text)

{

THIS.HTML = TEXT;

}

Public void setBodytext (String text)

{

IF (Control! = null)

{

IHTMLDocument2 Document = Control.getDocument ();

IF (Document! = NULL)

{

IHTMLELEMENT BODY = Document.getBody ();

IF (body! = null)

{

IF (Activate) DoverB (-4);

Body.setinnerhtml (Text);

Return;

}

}

}

THIS.BODY = TEXT;

}

Void me_handlecreated (Object S, Eventargs E)

{

Handlecreated - = New EventHandler (me_handlecreated);

IF (URL == String.empty)

{

URL = path.getTempFileName ();

Streamwriter Writer = New Streamwriter (URL, FALSE);

Writer.writeline (HTML);

Writer.flush ();

Writer.close ();

}

NaviGate (URL);

}

Void Me_naviGateComplete (Object S, BrowsernaviGateEventArgs E)

{

IF (Activate) DoverB (-4);

IF (HTML! = String.empty)

{

File.delete (URL); this.html = string.empty;

}

IF (body! = String.empty)

{

SetBodytext (body);

THIS.BODY = STRING.EMPTY;

}

}

Protected Override Void Createsink ()

{

Try

{

Cookie = New ConnectionPointCookie (Getocx (), this,

TypeOf (iWebBrowseRevents);

Catch {}

}

Protected Override Void Detachsink ()

{

Try {cookie.disconnect ();

Catch {}

}

Protected Override Void AttachInterfaces ()

{

Try {Control = (iWebBrowser) getocx ();

Catch {}

}

Protected Override Boolean IsInputKey (Keys KeyData)

{

Return (KeyData == Keys.escape)? false: Base.isinputKey (KeyData);

}

Public Void RaisebeforenaVigate (String Url, Int Flags, String

TargetFramen, Ref Object PostData, String Headers, Ref Boolean Cancel

{

BrowsernavigateEventArgs E = New BrowsernavigateEventArgs (URL, FALSE);

IF (beforenavigate! = null) BeforenaviGate (this, e);

Cancel = E.CANCEL;

}

Public Void RaisenaviGateComplete (String URL)

{

BrowsernavigateEventArgs E = New BrowsernavigateEventArgs (URL, FALSE);

IF (NavigateComplete! = NULL) NavigateComplete (this, e);

}

}

[GUID ("eab22ac2-30c1-11cf-a7eb-0000c05bae0b"),

InterfacePe (CominterFaceType.InterfaceiSidispatch)]

Public Interface IWebBBROWSEREVENTS

{

[Dispid (100)]

Void RaiseBeforenaviGate (String Url, Int Flags, String TargetFramen),

Ref Object PostData, String Headers, Ref Boolean Cancel;

[Dispid (101)]]

Void RaisenaviGateComplete (String URL);

}

Public Delegate Void Browsernavigate S, Object S,

BrowsernaVigateEventArgs E);

Public Class BrowsernaVigateEventArgs

{

String URL;

Boolean Cancel;

Public BrowsernavigateEventArgs (String Url, Boolean Cancel)

{

this.url = URL;

THIS.CANCEL = Cancel;

}

Public String URL

{

Get {return URL;}

}

Public Boolean Cancel

{

SET {Cancel = Value;}

Get {return

}

}

[GUID ("eab22ac1-30c1-11cf-a7eb-0000c05bae0b")]]]

Interface IWebBrowser

{

Void goback (); void goforward (); void gohome (); void gosearch ();

Void NaviGate (String Url, Ref Object Flags, Ref Object TargetFrame, REF

Object PostData, Ref Object Headers;

Void refresh (); void refresh2 (); void stop ();

Void getApplication (); void getparent (); void getContainer ();

[RETURN: MARSHALAS (UnmanagedType.Interface)]

IHTMLDocument2 getDocument ();

}

[GUID ("332C4425-26CB-11D0-B483-00C04FD90119"),

InterfacePeattribute (CominterFacetype.InterfaceIsDual), Comvisible (TRUE)]

Interface htmldocument2

{

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object getscript ();

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object getAll ();

[RETURN: MARSHALAS (UnmanagedType.Interface)]

IHTMLELEMENT getBody ();

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object getActiveEleMent ();

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object GetImages ();

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object getApplets ();

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object getLinks ();

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object getForms ();

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object getAnchors ();

Void setTitle ([IN, MARSHALAS (UNMANAGEDTYPE.BSTR)] String P);

[Return: Marshalas (unmanagedType.bstr)]

String gettitle ();

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object getscripts ();

Void setdesignmode ([IN, Marshalas (UnmanageDType.bstr)] String P);

[Return: Marshalas (unmanagedType.bstr)]

String getdesignmode ();

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object getselection ();

[RETURN: MARSHALAS (UnmanagedType.bstr)] String getReadyState ();

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object getframes ();

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object getembeds ();

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object getPlugins ();

Void SetalinkColor ([IN, Marshalas (UnmanagedType.struct)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getAlinkColor ();

Void setBgcolor ([IN, Marshalas (UnmanagedType.struct)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getBgcolor ();

Void setfgcolor ([IN, MARSHALAS (UNMANAGEDTYPE.STRUCT)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getfgcolor ();

Void setLinkColor ([IN, Marshalas (UnmanagedType.struct)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getLinkColor ();

Void SetVlinkColor ([IN, Marshalas (UnmanagedType.struct)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getVlinkColor ();

[Return: Marshalas (unmanagedType.bstr)]

String getreferrer ();

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object getLocation ();

[Return: Marshalas (unmanagedType.bstr)]

String getlastmodified ();

Void seturl ([IN, MARSHALAS (UNMANAGEDTYPE.BSTR)] String P);

[Return: Marshalas (unmanagedType.bstr)]

String geturl ();

Void setdomain ([IN, Marshalas (UnmanagedType.BSTR)] String P);

[Return: Marshalas (unmanagedType.bstr)]

String getdomain ();

Void setCookie ([IN, MARSHALAS (UNMANAGEDTYPE.BSTR)] String P);

[Return: Marshalas (unmanagedType.bstr)]

String getcookie ();

Void setExpando ([IN, MARSHALAS (UNMANAGEDTYPE.BOOL)] Boolean P);

[RETURN: MARSHALAS (UnmanagedType.Bool)] Boolean getExpando ();

Void setcharset ([IN, MARSHALAS (UNMANAGEDTYPE.BSTR)] String P);

[Return: Marshalas (unmanagedType.bstr)]

String getcharset (); void setDefaultcharset ([IN, Marshalas (unmanagedType.bstr)] String P);

[Return: Marshalas (unmanagedType.bstr)]

String getDefaultcharset ();

[Return: Marshalas (unmanagedType.bstr)]

String getMimens ();

[Return: Marshalas (unmanagedType.bstr)]

String getFileSize ();

[Return: Marshalas (unmanagedType.bstr)]

String getFilecreatedDate ();

[Return: Marshalas (unmanagedType.bstr)]

String getFileModifiedDate ();

[Return: Marshalas (unmanagedType.bstr)]

String getFileUpdatedDate ();

[Return: Marshalas (unmanagedType.bstr)]

String getsecurity ();

[Return: Marshalas (unmanagedType.bstr)]

String getProtocol ();

[Return: Marshalas (unmanagedType.bstr)]

String getNameProp ();

Void DummyWrite ([IN, Marshalas (UnmanagedType.i4)] Int Psarray);

Void DummyWriteln ([IN, Marshalas (UnmanagedType.i4)] Int Psarray);

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object Open ([IN, Marshalas (UnmanagedType.bstr)] String URL, [IN,

Marshalas (UnmanagedType.struct)] Object Name, [IN,

Marshalas (UnmanagedType.struct)] Object Features, [IN,

Marshalas (unmanagedType.struct)] Object Replace;

Void close ();

Void clear ();

[Return: Marshalas (unmanagedType.Bool)]

Boolean Querycommandsupported ([IN, Marshalas (unmanagedType.bstr)] String

Cmdid);

[Return: Marshalas (unmanagedType.Bool)]

Boolean Querycommandenabled ([IN, Marshalas (unmanagedType.bstr)] String

Cmdid);

[Return: Marshalas (unmanagedType.Bool)]

Boolean QuerycommandState ([IN, MARSHALAS (UNMANAGEDTYPE.BSTR)] String

Cmdid);

[Return: Marshalas (unmanagedType.Bool)]

Boolean QuerycommandIndeeeeeeTerm ([IN, MARSHALAS (UnmanagedType.bstr)] String

Cmdid);

[Return: Marshalas (unmanagedType.bstr)]

String querycommandtext ([IN, Marshalas (unmanagedType.bstr)] String cmdid);

[RETURN: MARSHALAS (UNMANAGEDTYPE.STRUCT)] Object QuerycommandValue ([IN, Marshalas (UnmanagedType.Bstr)] String

Cmdid);

[Return: Marshalas (unmanagedType.Bool)]

Boolean Execcommman ([IN, MARSHALAS (UNMANAGEDTYPE.BSTR)] String Cmdid, [IN,

Marshalas (UnmanagedType.Bool)] Boolean Showui, [IN,

Marshalas (unmanagedType.struct)] Object value);

[Return: Marshalas (unmanagedType.Bool)]

Boolean Execcommandshowhelp ([IN, Marshalas (UnmanagedType.bstr)] String

Cmdid);

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object CreateElement ([IN, MARSHALAS (UNMANAGEDTYPE.BSTR)] String ETAG);

Void setonhelp ([in, marshalas (unmanagedtype.struct)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonhelp ();

Void setonclick ([IN, MARSHALAS (UNMANAGEDTYPE.STRUCT)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonclick ();

Void setondblclick ([IN, MARSHALAS (UNMANAGEDTYPE.STRUCT)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getondblclick ();

Void setonkeyup ([IN, MARSHALAS (UNMANAGEDTYPE.STRUCT)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonkeyup ();

Void setonkeyDown ([IN, Marshalas (UnmanagedType.struct)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonkeydown ();

Void setonkeypress ([IN, Marshalas (UnmanageDType.struct)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonkeypress ();

Void setonmouseup ([IN, MARSHALAS (UnmanagedType.struct)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonmouseup ();

Void setonmousedown ([IN, Marshalas (UnmanagedType.struct)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonmousedown ();

Void setonmousemove ([IN, MARSHALAS (UNMANAGEDTYPE.STRUCT)] Object P);

[RETURN: MARSHALAS (UnmanagedType.struct)] Object getonmousemove ();

Void setonmouseout ([IN, MARSHALAS (UNMANAGEDTYPE.STRUCT)] OBJECT P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonmouseout ();

Void setonmouseover ([IN, MARSHALAS (UNMANAGEDTYPE.STRUCT)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonmouseover ();

Void setonreadyStateChange ([IN, Marshalas (unmanagedtype.struct)] Object

p);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonreadyStateChange ();

Void setonafterupdate ([IN, MARSHALAS (UNMANAGEDTYPE.STRUCT)] OBJECT P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonafterupdate ();

Void setonrowexit ([IN, Marshalas (unmanagedType.struct)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonrowit ();

Void setonrowenter ([IN, Marshalas (UnmanagedType.struct)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonroEnter ();

Void setondragStart ([IN, Marshalas (UnmanagedType.struct)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getondragstart ();

Void setonselectStart ([IN, Marshalas (unmanagedType.struct)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonselectstart ();

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object elementfrompoint ([in, marshalas (unmanagedtype.i4)] INT X, [IN,

Marshalas (unmanagedType.i4)] int y);

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object getParentWindow (); // htmlwindow2

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object getStylesheets ();

Void setonbeforeupdate ([IN, MARSHALAS (UNMANAGEDTYPE.STRUCT)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonbeforeupdate ();

Void setONERRORUPDATE ([IN, MARSHALAS (UNMANAGEDTYPE.STRUCT)] Object P);

[RETURN: MARSHALAS (UNMANAGEDTYPE.STRUCT)] Object getonerrorupdate ();

[Return: Marshalas (unmanagedType.bstr)]

String toString ();

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object createstylesheet ([in, marshalas (unmanagedtype.bstr)] String

BSTRHREF, [IN, MARSHALAS (UnmanagedType.i4)] INT LINDEX);

}

[GUID ("3050f1ff-98b5-11cf-bb82-00aa00bdce0b"),

InterfacePeattribute (CominterFacetype.InterfaceIsDual), Comvisible (TRUE)]

Interface htmlelement

{

Void setttribute ([IN, Marshalas (unmanagedtype.bstr)] String

Strattributename, [IN, Marshalas (unmanagedtype.struct)] Object

AttributeValue, [IN, Marshalas (UnmanagedType.i4)] int LFLAGS);

Void getaTtribute ([in, marshalas (unmanagedtype.bstr)] String

Strattributename, [in, marshalas (unmanagedtype.i4)] int LFLAGS, [OUT,

Marshalas (unmanagedtype.lparray)] Object [] pvars);

[Return: Marshalas (unmanagedType.Bool)]

Boolean Removeattribute ([IN, Marshalas (UnmanagedType.bstr)] String

Strattributename, [in, marshalas (unmanagedtype.i4)] int LFLAGS);

Void setClassName ([IN, MARSHALAS (UNMANAGEDTYPE.BSTR)] String P);

[Return: Marshalas (unmanagedType.bstr)]

String getclassname ();

Void SetID ([IN, Marshalas (UNMANAGEDTYPE.BSTR)] String P);

[Return: Marshalas (unmanagedType.bstr)]

String getId ();

[Return: Marshalas (unmanagedType.bstr)]

String gettagname ();

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Ihtmlelement getParentelement ();

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object getStyle (); // htmlstyle

Void setonhelp ([in, marshalas (unmanagedtype.struct)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonhelp ();

Void setonclick ([IN, MARSHALAS (UNMANAGEDTYPE.STRUCT)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonclick ();

Void setondblclick ([IN, MARSHALAS (UNMANAGEDTYPE.STRUCT)] Object P); [Return: marshalas (unmanagedType.struct)]

Object getondblclick ();

Void setonkeyDown ([IN, Marshalas (UnmanagedType.struct)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonkeydown ();

Void setonkeyup ([IN, MARSHALAS (UNMANAGEDTYPE.STRUCT)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonkeyup ();

Void setonkeypress ([IN, Marshalas (UnmanageDType.struct)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonkeypress ();

Void setonmouseout ([IN, MARSHALAS (UNMANAGEDTYPE.STRUCT)] OBJECT P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonmouseout ();

Void setonmouseover ([IN, MARSHALAS (UNMANAGEDTYPE.STRUCT)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonmouseover ();

Void setonmousemove ([IN, MARSHALAS (UNMANAGEDTYPE.STRUCT)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonmousemove ();

Void setonmousedown ([IN, Marshalas (UnmanagedType.struct)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonmousedown ();

Void setonmouseup ([IN, MARSHALAS (UnmanagedType.struct)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonmouseup ();

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object getDocument ();

Void setTitle ([IN, MARSHALAS (UNMANAGEDTYPE.BSTR)] String P);

[Return: Marshalas (unmanagedType.bstr)]

String gettitle ();

Void setLanguage ([IN, MARSHALAS (UNMANAGEDTYPE.BSTR)] String P);

[Return: Marshalas (unmanagedType.bstr)]

String getLanguage ();

Void setonselectStart ([IN, Marshalas (unmanagedType.struct)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonselectstart ();

Void Scrollintoview ([IN, Marshalas (UNMANAGEDTYPE.STRUCT)] ObjectVararGstart);

[Return: Marshalas (unmanagedType.Bool)]

Boolean Contain ([IN, Marshalas (UnmanagedType.Interface] htmlelement

PCHILD);

[RETURN: MARSHALAS (UnmanagedType.i4)]

INT getSourceIndex ();

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getRecordNumber ();

Void setLang ([IN, Marshalas (UNMANAGEDTYPE.BSTR)] String P);

[Return: Marshalas (unmanagedType.bstr)]

String getlang ();

[RETURN: MARSHALAS (UnmanagedType.i4)]

INT getoffsetleft ();

[RETURN: MARSHALAS (UnmanagedType.i4)]

INT getoffsettop ();

[RETURN: MARSHALAS (UnmanagedType.i4)]

Int getoffsetwidth ();

[RETURN: MARSHALAS (UnmanagedType.i4)]

Int getoffsetheight ();

[RETURN: MARSHALAS (UnmanagedType.Interface)]

IHTMLELEMENT GETOFFSETPARENT ();

Void SetinnerHTML ([IN, Marshalas (UNMANAGEDTYPE.BSTR)] String P);

[Return: Marshalas (unmanagedType.bstr)]

String getinnerhtml ();

Void Setinnertext ([IN, Marshalas (UNMANAGEDTYPE.BSTR)] String P);

[Return: Marshalas (unmanagedType.bstr)]

String getinnertext ();

Void setouterHTML ([IN, Marshalas (unmanagedType.bstr)] String P);

[Return: Marshalas (unmanagedType.bstr)]

String getouterhtml ();

Void setoutertext ([IN, Marshalas (unmanagedType.bstr)] String P);

[Return: Marshalas (unmanagedType.bstr)]

String getoutertext ();

Void insertjacenthtml ([in, marshalas (unmanagedtype.bstr)] String where,

String HTML; STRING HTML);

Void InsertJaceText ([IN, Marshalas (unmanagedType.bstr)] String where,

[IN, Marshalas (unmanagedtype.bstr)] String text);

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Ihtmlelement getParentTextedit ();

[Return: Marshalas (unmanagedType.Bool)]

Boolean getistextedit ();

Void Click ();

[RETURN: MARSHALAS (UnmanagedType.Interface] Object getfilters ();

Void setondragStart ([IN, Marshalas (UnmanagedType.struct)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getondragstart ();

[Return: Marshalas (unmanagedType.bstr)]

String toString ();

Void setonbeforeupdate ([IN, MARSHALAS (UNMANAGEDTYPE.STRUCT)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonbeforeupdate ();

Void setonafterupdate ([IN, MARSHALAS (UNMANAGEDTYPE.STRUCT)] OBJECT P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonafterupdate ();

Void setONERRORUPDATE ([IN, MARSHALAS (UNMANAGEDTYPE.STRUCT)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonerrorupdate ();

Void setonrowexit ([IN, Marshalas (unmanagedType.struct)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonrowit ();

Void setonrowenter ([IN, Marshalas (UnmanagedType.struct)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonroEnter ();

Void setondatasetchanged ([IN, MARSHALAS (UNMANAGEDTYPE.STRUCT)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getondataSetChanged ();

Void setondataavailable ([IN, MARSHALAS (UNMANAGEDTYPE.STRUCT)] OBJECT P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getondataavailable ();

Void setondatasetcomplete ([IN, MARSHALAS (UNMANAGEDTYPE.STRUCT)] OBJECT P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getondataSetComplete ();

Void setonfilterchange ([IN, MARSHALAS (UNMANAGEDTYPE.STRUCT)] Object P);

[RETURN: MARSHALAS (unmanagedType.struct)]

Object getonfilterchange ();

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object getChildren ();

[RETURN: MARSHALAS (UnmanagedType.Interface)]

Object getAll ();

}

}

And now some example code describing how to use it ... I created a window with a tree control at the left, the Internet Explorer at the right and a splitter in the middle so the controls can be resized dynamically ... using System;

Using system.drawing;

Using system.collections;

Using system.componentmodel;

Using system.windows.forms;

Using system.data;

Using system.threading;

Using reflector.library;

Namespace SPS2Admin

{

///

/// summary description for SPS2Admin.

///

Public Class SPS2Admin: System.Windows.Forms.form

{

///

/// ANTERNET Explorer Embedded Browser Instance IS Used for Displaying Detail Information.

///

Private HTMLBROWSER_HTMLBROWSER;

///

/// The tree for navigating sps structures.

///

Private TreeView Spstree;

Private system.windows.Forms.mainMenu mainmenu;

Private system.windows.Forms.MenuItem MenuItemFile;

Private system.windows.Forms.MenuItem MenuItemView;

Private system.windows.Forms.MenuItem MenuItemFileConnect;

Private system.windows.Forms.MenuItem MenuItemFileExit;

Private system.windows.Forms.MenuItem MenuItemViewWebs;

Private system.windows.Forms.MenuItem MenuItemcurrentcredentials;

Private system.windows.Forms.MenuItem MenuItemCreateProgram;

Private system.windows.Forms.MenuItem Menuitemnavigator;

///

/// Required Designer Variable.

///

Private system.componentmodel.Container Components = NULL;

Public SPS2Admin ()

{

//

// Required for Windows Form Designer Support

//

InitializationComponent ();

_htmlbrowser = new htmlbrowser ();

_htmlbrowser.parent = this;

_htmlbrowser.dock = DOCKSTYLE.FILL;

Splitter split = new splitter ();

Split.parent = this;

Split.dock = DockStyle.Left;

Split.backcolor = systemcolors.control;

SpStree = new treeView (); spstree.parent = this;

SpStree.dock = DockStyle.Left;

_htmlbrowser.navigate ("http://www.macaw.nl");

}

:

:

}

}

I DID DISPLY Only Some Relevant Part of The Code ... this stay do the job, no "design time" control, but hey .. who needs That!

Update: I got a solution from Julien CHEYSSIAL to resolve the problem concerning controls like textbox, combobox which were displayed with the old looking style while using the WebBrowser in a Windows Form application You have to add this meta in the head section of your pages. : . See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnie60/html/whatsnewpublicPreview.asp And http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/Userex/cookbook.asp for more info.

Posted on Sunday, August 31, 2003 3:50 PM

HREF = "http://weblogs.asp.net/soever/services/pingback.aspx" Rel = "pingback" />

Feedback # RE: Using IE Withnin A Windows Forms Application 4/3/2004 8:19 Am Patrick Tisseghem

You are Certainly Going to Love The WebBrowser Control In vs.net 2005! No more low-level plumbing - nice, clean management class!

#

Re: Using IE Withnin A Windows Forms Application

4/3/2004 8:19 AM

Patrick Tisseghem

You are Certainly Going to Love The WebBrowser Control In vs.net 2005! No more low-level plumbing - nice, clean management class!

转载请注明原文地址:https://www.9cbs.com/read-120109.html

New Post(0)