HTML Textbox -- like Outlook email message

Kenbuddy

Newcomer
Joined
Jul 10, 2002
Messages
13
Location
Cypress, TX
Can anyone give me any insight into what kind of control Microsoft uses for the message textbox when you are composing an email in Outlook (HTML format)? Is that an RTF textbox or a DHTML edit control, or something else?

The reason I'm asking is because I want to use a similar control in a database application I'm creating (a Windows forms control, not a web-based app). Currently, I am planning to use a RichTextBox control, but I'm thinking I might need something else. One of the things I want the user to be able to do is to copy text and images from their web browser and paste it into this field with the formatting pretty much in-tact, similar to the way you can copy articles and other stuff from the Web and paste it into an email. To do this, I am thinking I would need to use a DHTML edit control, or put a web browser control on my Windows form and set it to edit mode or something like that. Of course, whatever content is pasted into this control needs to be saved to the database so that it can be retrieved later in the same format.

Any ideas?
 
I'll skip answering the "which control to use" question and pose a possible issue. I recently read about the formatting of the text that is copied from IE to the clipboard. Apparently it's a bit messy (ok, a LOT messy). If you want to just support copying the text and maybe the image, you might be ok. The article I read mentioned a LOT of issues in that the text you copy may have styles applied and what shows up on the clipboard is not a simply block of HTML. You may have to grab some pieces and append them in the right place in your document, assuming it's HTML as well. If it's not, you may need to parse the HTML if you want to preserve such things as font (color and size), tables, etc. Thing about what would get copied if you highlighted one row from a table... having just a <TR> element isn't going to help you - you need the whole table definition, minus the other rows.

Anyway, I've never tried this before, but you may want to run some tests to see what you're dealing with (if you haven't already). It may help you decide what you'll need later (RTF codes or HTML).

Sorry I don't remember the article, but it was from this month or last and was probably Visual Studio magazine (formerly VBPJ) or MSDN magazine, if you wanted to look. I think it was in a Q&A section but I forget that, too :)

-Nerseus
 
I'd use the DHTML Edit control, if that's what you need. It does everything you want to, and you can take the HTML for the document and stick it in to a database easily.

You already have this control, it ships with Internet Explorer. If you have vs.net, the latest version is probably installed here:

Program Files\Common Files\Microsoft Shared\Triedit\dhtmled.ocx
 
Any practical pointers on how to go about using the DHTML Edit Control? I searched the Internet and came up with a lot of confusing information about it. The thing I'm most confused about is that MS has abandoned the DHTML Edit Control in favor for the MSHTML Edit Control, but from what I can tell, it's not just a matter of putting a simple control on a form and tweaking its properties. I think you have to start with the Web Browser control, set up an HTML document object, and then set up some kind of Edit Designers. I was hoping for something like an all-in-one, do it yourself kind of control. If I go with the older, apparently discontinued DHTML Edit Control, I don't know if the process is any simpler (although I know it doesn't use "Edit Designers" whatever they are).
 
I'd use the DHTML Edit control. It may have been dropped in favour of using MSHTML directly, but you're not going to be able to do that in .NET unless you have a handy IOleObject definition around. The DHTML Edit control is still used a great deal.

That said, you could probably gain access to the same functions by dropping a webbrowser control on your form and using the HTML DOM to enable editing. It wouldn't contain any of the handy functions the other does for displaying formatting tools, etc, though.

Both of those controls can be added to your toolbox, under DHTML Edit Control and Microsoft Web Browser respectively.
 
Back
Top