OLE Clipboard :: Win32 API vs. MFC

Started by
3 comments, last by kuphryn 21 years, 8 months ago
Hi. I use Programming Windows with MFC, Second Edition by Jeff Prosise as a reference for the OLE Clipboard. Prosise demonstrates both Win32 API method and MFC simple classes encapsulating the Win32 API method for the OLE Clipboard. The Win32 API method is not difficult, just takes up a little bit more code than if you use MFC. I would like to know is there any advantage to using Win32 API instead of MFC for OLE Clipboard and even COM? I enjoy working with Win32 API, but not for GUI. Thanks, Kuphryn
Advertisement
Okay. I tested an OLE Clipboard implementation with some lines of text. Everything works good, except for that fact that the data buffer ingored all newlines. For example, let this copy the following data, which I first save in a string object, to the OLE Clipboard.

-----
Test
1
2
3
Testing Completed
-----

This is what I would see when I paste to Notepad.

-----
Test[]1[]2[]3[]Testing Completed
-----

I am using the OLE Clipboard strictly for text. I would like to know is it possible to copy data to the clipboard so Windows would recognize all new lines?

Thanks,
Kuphryn
Some text editors need ''\r'' ''\n'' as new line. Some need just ''\n'' as new line... or some even just need ''\r'' for new line... complicated, isn''t it?
"after many years of singularity, i'm still searching on the event horizon"
I''m guessing what you''ve got typed as [] is really a box in Notepad? If so, that''s a character that''s unprintable in the current character set. Most likely either a linefeed or carriage return. Some systems (I believe mostly Unix? Anyone?) use both CR (carriage return; 0x0d) and LF (linefeed; 0x0a), while most Windows machines use only 0x0d. So possibly your program is only writing one and not the other, while Notepad is expecting both? Try what Dereksaw has suggested, I''d expect this to fix the problem.
Thanks. "\r\n" is the solution. I used "\n," but I really needed "\r\n."

Kuphryn

This topic is closed to new replies.

Advertisement