Sorry for not getting back to you Alessandro. I actually spent a few
hours on this issue late sunday night and was tied all of today on
business.
First the CF_HTML clipboard format requires a header.
Here is a sample.
Version:1.0
StartHTML:000000174
EndHTML:000000886
StartFragment:000000610
EndFragment:000000725
StartSelection:000000650
EndSelection:000000725
SourceURL:about
:blank
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD></HEAD>
<BODY>
<FONT face=Arial>
<FONT size=7>
<FONT style="BACKGROUND-COLOR: #000000" color=#ffffff>
<FONT size=1>
<FONT size=1>
<FONT style="BACKGROUND-COLOR: #ffffff">
<FONT color=#000000>
<STRONG>
<FONT face=Arial>
<FONT size=7>
<FONT style="BACKGROUND-COLOR: #000000" color=#ffffff>
<FONT size=1>
<FONT size=1>
<P><!--StartFragment--><FONT style="BACKGROUND-COLOR: #ffffff"><FONT
color=#0000ff>This is bold and <EM>this is
italic.</EM></FONT></FONT><!--EndFragment--></P>
</FONT>
</FONT>
</FONT>
</FONT>
</FONT>
</STRONG>
</FONT>
</FONT>
</FONT>
</FONT>
</FONT>
</FONT>
</FONT>
</BODY>
</HTML>
A doc detailing the header is here but it is for the older .9 version.
http://msdn.microsoft.com/library/de.../en-us/winui/w
inui/windowsuserinterface/dataexchange/clipboard/htmlclipboardformat.asp
VB Source code for creating the header is here:
http://support.microsoft.com/default...b;en-us;274326
Now as you have discovered you can manually cut and paste from Internet
Explorer to the RTF control. But if you programmatically build the
identical CF_HTML string you can place it on the Clipboard but you
cannot paste it into the RTF control. It would seem the application(IE)
originating the HTML is resonsible for generating the RTF string. The
Clipboard object cannot directly generate RTF from HTML. It asks the
originating appllication that places the HTML on the Clipboard to
generate the RTF string.
I swear that I have read in the bowels of the MSDN OLE documentation
that the Clipboard object can convert from HTML to RTF independant of
the application that places the HTML on the Clipboard. I have searched
but cannot find the reference. Perhaps it is an operating system
function that is not exposed but available to Microsoft applications
only. I'm sure it is out there somewhere.
Anyhow, you would seem to have two choices.
1) Use the HTML Editor on my site and forget about the RTF control.
2) Use the HTML Editor and the RTF control. If you place the MS Web
Browser control on a form you can programmatically issue the OLE
Method(Action prop = 4) to copy the contents of the control to the
Clipboard. YOu can then programmatically set focus to the RTF control
and issue a Paste command and vice versa. If you do not want to place
the Web Browser control ona form you could instantiate an instance of
Internet Explore and use it instead.
Let me know how you make out.
--
HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"ALESSANDRO Baraldi" <ik****@libero.it> wrote in message
news:co**********@lacerta.tiscalinet.it...
Good evening.
Few day ago i ask about this Object.
A very kindly replay of Sthepen Lebans give me the solution
to use ClipBoard to synthesise the Conversion, but i've some truble.
My scene:
I use a RichTextBox to write the Formatted Text, and i need
to send the content by Mail with Winsok.
To do this i need to format then Body on HTML.
On reverse when i receive HTML Mail i extract HTML message
and i put it on Web Browser control.
So now i have a question:
If i use textRTF property Control and i copy this on Clipboard it's
like a Text only and my conversion it's impossible, because the HTML format
is not available.
I register RegisterClipboardFormat("HTML Format"), but with a
ClipBoard Viewer
i can't see it like available to covert my textRTF.
If i make a Selection by mouse and copy with CTRL+C i have HTML format
available
and i can convert my RTFText on HTML....!!!
What can be my mistake..?
This is the code to copy on Clipboard, taken from Lebans Demo
First i register the new format:
CF_RTF = RegisterClipboardFormat("Rich Text Format")
CF_HTML= RegisterClipboardFormat("HTML Format")
After i copy
Function SetClipBoard(strRTF_IN As String) As Boolean
Dim hMainMem As Long
Dim lpMainMem As Long
Dim hCMem As Long
hMainMem = GlobalAlloc(GHND, Len(strRTF_IN) + 1)
lpMainMem = GlobalLock(hMainMem )
lpMainMem = lstrcpy(lpMainMem , strRTF_IN)
If GlobalUnlock(hMainMem ) = 0 Then
If OpenClipboard(0&) <> 0 Then
Call EmptyClipboard
hCMem = SetClipboardData(CF_RTF, hMainMem )
SetClipBoard = CBool(CloseClipboard)
End If
End If
End Function
Here no HTML available conversion on ClipBoard.
Thanks to all for any suggestion
--
(Alessandro Baraldi)