Create and launch html page?

M

Mervin Williams

From within a Windows form, I need create a html page and open it within
Internet Explorer. Does anyone know whether this is possible within a
Windows Forms application? If so, please provide an example.

Thanks in advance,

Mervin Williams
 
C

Cor Ligthert [MVP]

Mervin,

If it is only opening it and the extention is Html

\\\Internet Explorer C#
System.Diagnostics.Process p =
new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo pi =
new System.Diagnostics.ProcessStartInfo();
pi.FileName = "http://www.google.com";
p.StartInfo = pi;
p.Start();
///

I hope this helps,

Cor
 
G

Guest

oIE = CreateObject("InternetExplorer.Application")
oIE.Navigate("about:blank")
oIE.ToolBar = True
oIE.MenuBar = False
oIE.AddressBar = False
oIE.StatusBar = False
oIE.Visible = True
oIE.Document.Title = "bla bla bla"
oIE.Document.Body.InnerHTML = "This Page Generated on the
Fly<br>bla bla bla..."
 
W

wooster11

Just another method I'm listing here. You can just shell off Internet
Explorer from your app. (VB .NET only)

Shell("iexplore.exe http://www.google.com")

There are also some other arguments to the Shell method which you can
just lookup in the help (MSDN library) if you want to use them (Window
Style, Wait for the application to finish, and timeout). They are all
optional though. If you want to just launch it and let it go, then
just do the line of code above.

Derek Woo
 
M

Mervin Williams

Is there a corresponding CreateObject(string) method in C#?

Mervin Williams
 
D

David

Are you trying to contruct the html for the page yourself, then push the in
memory html into the browser? You can host the webbrowser control in your
application if so:

Add the webbrowser control from the designer and give it a name. In the
below example, I have "wb_unifiedReport"

private AxSHDocVw.AxWebBrowser wb_unifiedReport;

then to initialize, you must first navigate to some page to force mshtml to
load so oyou can use the dom and set your own text. (Alternatively, if you
just want to navigate to a page, just put the url below instead of
about:blank.

// Prepare the webbrowser control for use (forces load of mshtml)
object o = null;

wb_unifiedReport.Navigate("about:blank", ref o, ref o, ref o, ref o);

Now to set your own text

BrowserProxy.SetBrowserInnerHTML( wb_unifiedReport, strHTML );

This is a custom class of mine, but here is the code for the method:

public static void SetBrowserHTML( AxSHDocVw.AxWebBrowser browser, string
strHTML )

{

//string url = "about:blank";

//object o = null;//System.Reflection.Missing.Value;

//browser.Navigate ( url,ref o,ref o,ref o,ref o);

object[] psa = {strHTML};

MSHTML.IHTMLDocument2 hDoc2 = (MSHTML.IHTMLDocument2)(browser.Document);

hDoc2.clear();

hDoc2.write(psa);

hDoc2.close();

}

Now you can create your own web documents in memory and push into a hosted
web browser control.

-David
 
G

Guest

object oIE = null;
oIE = Interaction.CreateObject( "InternetExplorer.Application", "" );
 
M

Michael J. Ryan (tracker1)

Mervin said:
From within a Windows form, I need create a html page and open it within
Internet Explorer. Does anyone know whether this is possible within a
Windows Forms application? If so, please provide an example.

save the file to the filesystem in a temp location, and use
Process.Start("iexplore.exe", "file://X:/.../filename.ext")
should be similar to that.. (off the top of my head).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top