HtmlEditor update

  • Thread starter Thread starter Tim Anderson
  • Start date Start date
T

Tim Anderson

I've posted an update to the HtmlEditor - hosts Msthml in C#. I've removed
the dependency on Microsoft.mshtml. See here:

http://www.itwriting.com/htmleditor

It would be nice to be able to use the DOM in System.Windows.Forms with the
control. You can easily get the unmanaged DomDocument from a managed
HtmlDocument. Does anyone know a way to do the opposite?

Tim
Tech blog: http://www.itwriting.com/blog
 
HI Tim,

Usually an announcement post is preceded with an ANN prefix in the subjetc.
 
Hi,

Opps, sorry I did not read the last sentence

And no, I don;t know how to do so. and frankly don't think that the
unmanaged DOM keeps a reference to the containing HtmlDocument
 
And no, I don;t know how to do so. and frankly don't think that the
unmanaged DOM keeps a reference to the containing HtmlDocument

The unmanaged DOM has no knowledge of any .NET classes. However I'd have
thought there could be a constructor somewhere that creates a managed
HtmlDocument from a reference to an unmanaged HTMLDocument, without actually
displaying it in the WebBrowser control.

Tim
Tech blog: http://www.itwriting.com/blog
 
Hi Tim,

I think you may try the method below.
NOTE: you need to have the interface and the interface must be valid. That
is to say, the interface should be pointed to an Object which have been
created.
Marshal.GetObjectForIUnknown Method
http://msdn2.microsoft.com/en-US/library/system.runtime.interopservices.mars
hal.getobjectforiunknown.aspx

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
I think you may try the method below.
NOTE: you need to have the interface and the interface must be valid. That
is to say, the interface should be pointed to an Object which have been
created.
Marshal.GetObjectForIUnknown Method

Peter,

Thanks for the suggestion. You may have misunderstood the requirement. This
method (and the similar Marshal.GetTypedObjectForIUnknown) can only return a
wrapper generated by the type library importer. This is not the case with
System.Windows.Forms.HtmlDocument.

Tim
Tech blog: http://www.itwriting.com/blog
 
Hi Tim,

I understand your scenario, if you look at the HTMLDocument class, it did
not include a ctor or a method to create a HTMLDocument based on a
IHTMLDocument interface. Actually this is somewhat a kind of .NET wrap.

If we look into the HTMLDocument class in MSDN, we will get the definition
as below.
Note: This class is new in the .NET Framework version 2.0.
Provides top-level programmatic access to an HTML document hosted by the
WebBrowser control.

As you said, the unmanaged HTMLDocument interface did not include a
reference to a managed HTMLDocument class.
So according to the document, the HTMLDocument class is used to help to
access to an HTML document hosted by the WebBrowser control. That is why it
did not have a ctor to create a HTMLDocument.

Also from your description below
"It would be nice to be able to use the DOM in System.Windows.Forms with
the
control. You can easily get the unmanaged DomDocument from a managed
HtmlDocument. Does anyone know a way to do the opposite?"

So I understand that you already have a unmanaged DomDocument, and you want
to get its managed reference. As you said in the previous post,
Marshal.GetTypedObjectForIUnknown will get a wrapper generated by MSHTML
COM TypeLib which is provided by MS. I just wonder why you did not want use
the wrapper. If you do not want to use MSHTML library in .NET, I think you
have to build one HTML .NET wrapper yourself. This should be complex job,
if you do wanna do that, I suggest you contact MSPSS directly.

http://support.microsoft.com

If I have any misunderstanding or you have any concern, please feel free to
post here.

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
"Peter Huang" said:
Hi Tim,

I understand your scenario, if you look at the HTMLDocument class, it did
not include a ctor or a method to create a HTMLDocument based on a
IHTMLDocument interface. Actually this is somewhat a kind of .NET wrap.

Yes - there is a constructor of course but it is marked internal so not
accessible.
So I understand that you already have a unmanaged DomDocument, and you
want
to get its managed reference. As you said in the previous post,
Marshal.GetTypedObjectForIUnknown will get a wrapper generated by MSHTML
COM TypeLib which is provided by MS. I just wonder why you did not want
use
the wrapper.

Just to be clear, there are two wrappers under discussion here. There is the
..NET 2.0 wrapper which is part of the Framework (HtmlDocument etc), and
Microsoft.Mshtml which is the PIA for MSHTML. It's the former that I want to
use, not the latter. The main problem with the latter, by the way, is its
large size and the fact that it is not distributed with dotnetfx.exe but has
to be deployed separately; there are also some bugs in its implementation.

If you look at the documentation for the .NET 2.0 wrapper (as opposed to the
PIA), you'll note that it is only a subset of what is in MSHTML. Further,
the WebBrowser control does not offer an edit mode; you can set designmode
on via DomDocument, but there seem to be some bugs and problems with this
(I've not fully investigated). In addition, there are scenarios where you
might want to process HTML without displaying anything in the WebBrowser
control.
If you do not want to use MSHTML library in .NET, I think you
have to build one HTML .NET wrapper yourself. This should be complex job,

Yes, this is what I've done; but I find it frustrating that you can't use
the nice MSHTML wrapper built into .NET Framework 2.0 for documents that are
not loaded into the WebBrowser control.

My wrapper is here:

http://www.itwriting.com/htmleditor/index.php

Tim
 
Hi Tim,

I do understand your concern in this scenario, I highly suggest you can
submit this feedback to our product feedback center:

http://lab.msdn.microsoft.com/productfeedback/default.aspx

Our feedback team will consider your suggestion and keep improving our
product.

Thanks for your understanding!


Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

Back
Top