Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


CF_HTML format for Clipboard functions

Keywords:   CF_HTML format for Clipboard functions

Question:

Is there a way to get the contents (CF_HTML format) of the clipboard into a Binary Buffer without altering the contents?

I am trying to save a few web pages into individual buffers for later pasting into an excel worksheet. Using the Inet Extender is not an option due to the way that the navigation of the site has to take place. I am currently using OLE to control IE.

I looked up the BinaryClipGet and the BinaryClipPut functions, but they don't seem to support the CF_HTML format. When I try using any of the other valid formats (F_TEXT, CF_OEMTEXT, CF_UNICODETEXT) and then dumping the binary buffer contents back into the clipboard, the html formatting is lost.

More info on the CF_HTML format can be found at:

http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/clipboard/htmlclipboard.asp  
Any ideas?

Answer:

This'll do it:
;keywords CF_HTML HTML Format Clipboard

dllname=StrCat(DirWindows(1),"user32.dll")
CF_HTML=DllCall(dllname,long:"RegisterClipboardFormatA",lpstr:"HTML Format")

size=BinaryClipGet(0,CF_HTML)
bb=BinaryAlloc(size)
BinaryClipGet(bb,CF_HTML)

data=BinaryPeekStr(bb,0,size)
BinaryFree(bb)
Message("",data)

Article ID:   W15345