473,383 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

HTML in Win Forms?

Is there a way to display formatted HTML in a Windows form? Or can I
dynamically create an HTML file and then display that from a Windows
Application? I can create a new HTML file in my project, but how do I
reference it within my code, so I can manipulate it? Thanks.

Nov 20 '05 #1
8 5393
Well, I'm getting closer. I added "SHDocVw.WebBrowserClass" with the
Customize Toolbox. However, I can't load it with HTML because it's
ready-only. I could create a HTML file and then navigate to it, but
that's too clumsy. Anyone have a better idea?

copyco wrote:
Is there a way to display formatted HTML in a Windows form? Or can I
dynamically create an HTML file and then display that from a Windows
Application? I can create a new HTML file in my project, but how do I
reference it within my code, so I can manipulate it? Thanks.


Nov 20 '05 #2
Cor
Hi copyco,
Well, I'm getting closer. I added "SHDocVw.WebBrowserClass" with the
Customize Toolbox. However, I can't load it with HTML because it's
ready-only. I could create a HTML file and then navigate to it, but
that's too clumsy. Anyone have a better idea?


I think that the answer on your question is given on 19-9-2003 by Charles
Law (shdocvw)
A part of what he did write was
Dim doc1 As mshtml.IHTMLDocument2
doc1 = DirectCast(AxWebBrowser1.Document, mshtml.IHTMLDocument2)


I do not know if you do need the IHTMLDocument2 or just the
mshtml.HTMLDocument.
This was for a scroll activity.
But I think this will set you on the route.

I hope this helps
Cor

End please message us when you did succeed?

Nov 20 '05 #3

Cor wrote:
Hi copyco,
Well, I'm getting closer. I added "SHDocVw.WebBrowserClass" with the
Customize Toolbox. However, I can't load it with HTML because it's
ready-only. I could create a HTML file and then navigate to it, but
that's too clumsy. Anyone have a better idea?

I think that the answer on your question is given on 19-9-2003 by Charles
Law (shdocvw)
A part of what he did write was
Dim doc1 As mshtml.IHTMLDocument2
doc1 = DirectCast(AxWebBrowser1.Document, mshtml.IHTMLDocument2)

I do not know if you do need the IHTMLDocument2 or just the
mshtml.HTMLDocument.
This was for a scroll activity.
But I think this will set you on the route.

I hope this helps
Cor

End please message us when you did succeed?


I don't seem to have the "HTMLDocument" or "IHTMLDocument2" methods
available in my object. Perhaps my object is different in some way, or
I just don't know how to set it up properly. Mine is called "Microsoft
Web Browser."

Nov 20 '05 #4
Cor
Hi Copyco,
You have to set a reference to microsoft.mshtml
And as an advice, don't do an import that makes your IDE terrible slow,
Use always the full reverence like mshtml.htmldocument or so.
That goes too slow, but when you make an import almost everything becomes
slow in your IDE
Cor.
Nov 20 '05 #5
Hello,

"copyco" <co****@anon.com> schrieb:
Is there a way to display formatted HTML in a Windows form?


311303 WebOCHostVB.exe Hosts the WebBrowser Control in Visual Basic .NET
http://support.microsoft.com/?id=311303

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #6
Ok, assuming I get some value loaded into mshtml.htmldocument. How
would I then get that to display in a form? How would I load that into
the web browser object? The one I'm trying to use, the .document method
is read-only. Thanks.

Cor wrote:
Hi Copyco,
You have to set a reference to microsoft.mshtml
And as an advice, don't do an import that makes your IDE terrible slow,
Use always the full reverence like mshtml.htmldocument or so.
That goes too slow, but when you make an import almost everything becomes
slow in your IDE
Cor.


Nov 20 '05 #7
Cor
Copyco
You have now a document according to the DOM (document object model).
It is not the smallest object model, to do more with it; you would have to
do the same as most of us, investigate the object model and see what you can
do with it.

The DOM is the most important object model that IE works with.
I don't know if it fits for you. But you have now two major object models to
do your work.
The webbrowser and the DOM, but both are not the easiest ones.

Succes

Cor

Nov 20 '05 #8
Hi

To create an HTML document in memory, I recommend the following:

<code>
Imports System.Runtime.InteropServices

' IPersistStreamInit interface
<ComVisible(True), ComImport(),
Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"), _
InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIUnknown)> _
Public Interface IPersistStreamInit
Sub GetClassID(ByRef pClassID As Guid)

<PreserveSig()> Function IsDirty() As Integer
<PreserveSig()> Function Load(ByVal pstm As UCOMIStream) As Integer
<PreserveSig()> Function Save(ByVal pstm As UCOMIStream, ByVal fClearDirty
As Boolean) As Integer
<PreserveSig()> Function GetSizeMax(<InAttribute(), Out(),
MarshalAs(UnmanagedType.U8)> ByRef pcbSize As Long) As Integer
<PreserveSig()> Function InitNew() As Integer
End Interface

Private Function CreateDocument() As mshtml.IHTMLDocument2

Dim doc2 As mshtml.IHTMLDocument2
Dim ips As IPersistStreamInit

' Create a new document
doc2 = New mshtml.HTMLDocument

ips = DirectCast(doc2, IPersistStreamInit)

' Initialise the document
ips.InitNew()

' Wait until initialisation is complete
Do Until doc2.readyState = "complete"
Application.DoEvents()
Loop

Return doc2

End Function
</code>

This will create an initialisesd document that you can manipulate.

Include a reference to Microsoft.mshtml in your project, but as Cor
suggested, do not include an imports for mshtml, but qualify declarations
with it instead. Mshtml contains hundreds of interfaces that take a
noticeable time to load each time you type Dim x As ...

Once you have an interface to the document (doc2) you can manipulate it
through this and other interfaces.

ips.Load will load the document from a stream, but remember to wait for
doc2.readstate to be "complete" before accessing the document; docuemnts are
loaded asynchronously.

Feel free to post back further questions. You may also like to look at

microsoft.public.inetsdk.programming.mshtml_hostin g
microsoft.public.inetsdk.programming.webbrowser_ct l

I tend to post answers to this type of question here as they crop up quite
frequently. When I have a moment ( ;-) ) I will try to put together a small
app that demonstrates a lot of the techniques.

HTH

Charles
"copyco" <co****@anon.com> wrote in message
news:qd****************@newssvr24.news.prodigy.com ...
Is there a way to display formatted HTML in a Windows form? Or can I
dynamically create an HTML file and then display that from a Windows
Application? I can create a new HTML file in my project, but how do I
reference it within my code, so I can manipulate it? Thanks.

Nov 20 '05 #9

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

Similar topics

7
by: Bob Nolty | last post by:
Hi all -- I'm trying to create a hidden form in the document using only Javascript -- I don't know what form I want until the user clicks a button -- I tried the following code, which does...
4
by: VK | last post by:
09/30/03 Phil Powell posted his "Radio buttons do not appear checked" question. This question led to a long discussion about the naming rules applying to variables, objects, methods and properties...
22
by: Luke | last post by:
Elements with name attribute: form, input, textarea, a, frame, iframe, button, select, map, meta, applet, object, param, img (if you know more reply...) Methods of addresing html elements:...
2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
6
by: William F. Zachmann | last post by:
We've got a project going that involves moving an old web site with a massive dll written in C++ that produces most of the output from a SQL 7.0 data base on NT4 onto IIS on Windows 2003 Server...
4
by: Sathyaish | last post by:
I am no JavaScript progammer, and unfortunately am having to babysit an old code base that has a lot of JavaScript in it. I have two questions: (1) Can two HTML controls have the same name? It...
5
by: nick | last post by:
I need to create a simple asp.net application that use password protect some html pages. The html page provider doesn't know asp.net. And the host doesn't allow me to create user accounts. ...
7
by: thersitz | last post by:
I can't seem to get my html form to submit properly from within a web form. Here's my form tag syntax and some delivery hidden fields. <form id="myForm"...
19
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect...
1
by: since | last post by:
I figured I would post my solution to the following. Resizable column tables. Search and replace values in a table. (IE only) Scrollable tables. Sortable tables. It is based on a lot...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.