Projects/CoVNC
html을 클립보드에 복사
>동네청년<
2007. 7. 25. 03:25
rich text의 경우 richedit.h만 include해주면 MFC가 아닌 Win32 API를 사용하는 프로그램에서도CF_RTF를 사용할 수 있었지만 HTML은 아직 발견하지 못했네요.
다음 예는 msdn에 올라와있는 예제입니다만,,, MFC에서만 사용가능 한 것으로 생각됩니다...
RegisterClipboardFormat("HTML Format"); 함수를 사용했고 이것을 사용해 setClipboardData()함수를 호출 하였지만 클립보드에 html 데이터가 들어가지 못합니다...
그나저나 빨리 CF_HTML 을 사용할 수 있도록 하는 방법을 찾아야 하는데,,, 잠도 못자고 죽겠네여....
How To Add HTML Code to the Clipboard by Using Visual C++
This article was previously published under Q274308
SUMMARY
This article demonstrates how to add Hypertext Markup Language (HTML) to the Microsoft Windows clipboard by using Visual C++. It also includes a sample function that you can use in your applications to simplify the process.
MORE INFORMATION
HTML has its own clipboard format called HTML Format (CF_HTML) that you can use to provide your data to other applications, such as Microsoft Excel, Microsoft Word, or other Microsoft Office applications.
CF_HTML is entirely a text-based format that includes a description, a context, and a fragment within that context. When you build data to send to the clipboard, you must include a description of the data to indicate the clipboard version and the offsets for the context and fragment. Calculating the offsets can be the difficult part. However, you can use the following routine to simplify this task:
CF_HTML is entirely a text-based format that includes a description, a context, and a fragment within that context. When you build data to send to the clipboard, you must include a description of the data to indicate the clipboard version and the offsets for the context and fragment. Calculating the offsets can be the difficult part. However, you can use the following routine to simplify this task:
// CopyHtml() - Copies given HTML to the clipboard. |
When you use this function to copy an HTML code fragment to the clipboard, it might look like the following:
char *html = |
Additional Note
Using an approach that sends HTML code to the clipboard might be especially beneficial for Office Automation clients. For example, if you have an Automation client that needs to generate formatted data for cells in Microsoft Excel or paragraphs in Microsoft Word, you could build the data in HTML code, send it to the clipboard, and then paste it into the application. By using this technique, you could reduce the number of out-of-process calls to the Automation client.
REFERENCES
To learn more about the specifics of the HTML Clipboard format, see the topic "HTML Clipboard Format" in the MSDN: