My question is, do functions like EnumClipboardFormats or
GetPriorityClipboardFormat give me in first place exactly the format in
which the text originated?
--
Regards,
Alexander Kamburov
Short: No.
Long: ther is no direct link between the the clipboard format and the
"original format." In many cases the original format is proprietary and you
will have no way to understand it.
When I copy some text from Corel Draw I get the following formats:
1 Object Descriptor CF_TEXT
2 Ole Private Data CF_BITMAP
3 Corel 32-bit Presentation Exchange Data CF_METAFILEPICT
7 Ole Private Data CF_OEMTEXT
8 Corel 32-bit Presentation Exchange Data CF_DIB
13 Ole Private Data CF_UNICODETEXT
14 Corel 32-bit Presentation Exchange Data CF_ENHMETAFILE
16 Ole Private Data CF_LOCALE
17 Ole Private Data CF_MAX
49161 DataObject <UNKNOWN>
49163 Embed Source <UNKNOWN>
49156 Native <UNKNOWN>
49155 OwnerLink <UNKNOWN>
49166 Object Descriptor <UNKNOWN>
49687 Corel 32-bit Presentation Exchange Data <UNKNOWN>
49689 Corel Presentation Exchange Data <UNKNOWN>
49171 Ole Private Data <UNKNOWN>
I assume the "original format" is 49156 (Native). But this is not a rule.
And since I don't know the native Corel format, this is useless.
To increase compatibility the applictions try to put into the clipboard as
many formats as possible.
Just take the one with max. information that you can still understand (in
your case is probable CF_UNICODETEXT). If you can can use RTF, then you
also get font information etc.
Mihai
When I copy an AnsiString to clipboard the CF_UNICODETEXT returns it as
WideString. I mean it doesn't convert it but passes it as if it is Unicode.
Doing so the WideString is half the length of the original and of course it
is totally not what I want.
When I copy a WideString to clipboard the CF_TEXT returns a normal string
and in the place of spec chars I get question marks. I made my program check
if there are any question marks in the AnsiString and if found to use
CF_UNICODETEXT. This is the only solution I was able to come out with and as
you can see it's not the most robust.
Reading my current posting again I see that there is a possiblility that I
have a bug in my function that takes the text under CF_UNICODETEXT but I
don't have acces to my source code at this moment.
--
Regards,
Alexander Kamburov
wise_...@yahoo.com
"Mihai N." <nmiha...@yahoo.com> wrote in message
news:Xns93279DA...@63.240.76.16...
--
Regards,
Alexander Kamburov
--
MichKa [MS]
This posting is provided "AS IS" with
no warranties, and confers no rights.
"Alexander Kamburov" <wise_...@yahoo.com> wrote in message
news:e3ZFebA2CHA.1560@TK2MSFTNGP09...
> You cannot. You should ask for whatever format you need.
Well then how come the first format returned by EnumClipboardFormats is
changing according to the text encoding. I tryed it under XP. When I copy
Ansi the main format is CF_TEXT when I copy Unicode the EnumClipboardFormats
returns CF_UNICODETEXT in first place. It's true that the MSDN doesn't tell
you nothing about this functionality but may be the code used for this
operations does this by himself.
Quote from help on EnumClipboardFormats: "When format is zero, the function
retrieves the first available clipboard format". May be this is why the
first format when copying text is the right one. Anyway, if this isn't so
and I'm mistaking the I think this is some type of bug in the Clipboard
functions.
--
Regards,
Alexander Kamburov
wise_...@yahoo.com
"Michael (michka) Kaplan [MS]" <mic...@online.microsoft.com> wrote in
message news:u#4FjvA2C...@TK2MSFTNGP11.phx.gbl...
--
MichKa [MS]
This posting is provided "AS IS" with
no warranties, and confers no rights.
"Alexander Kamburov" <wise_...@yahoo.com> wrote in message
news:OqpeeL92...@TK2MSFTNGP11.phx.gbl...
Synthesized Clipboard Formats
The system implicitly converts data between certain clipboard formats: if
a window requests data in a format that is not on the clipboard, the
system converts an available format to the requested format. The system
can convert data as indicated in the following table.
...
If the system provides an automatic type conversion for a particular
clipboard format, and you call EnumClipboardFormats to enumerate the
clipboard data formats, the system first enumerates the format that is on
the clipboard, followed by the formats to which it can be converted.
from http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/winui/winui/windowsuserinterface/dataexchange/clipboard/clipboardforma
ts.asp
Mike
My guess is that if unicode text is put on the clipboard, the conversion
uses the system code page to convert it to CF_TEXT and I think it puts
?'s in for unicode characters that can't be represented by that code
page. There isn't much else it could do.
I am surprised that there is ever a problem getting the CF_UNICODETEXT
though, but that's based just on how I think this should work, not any
experience with it.
"Michael \(michka\) Kaplan [MS]" <mic...@online.microsoft.com> wrote in
news:et8inVA3...@TK2MSFTNGP10.phx.gbl:
> The function is not guaranteed to be deterministic about its ordering
> and is certainly not documented as working the way you want it to for
> all versions (or for all future versions).
>
>
--
MichKa [MS]
This posting is provided "AS IS" with
no warranties, and confers no rights.
"Michael Lippert" <mlipp...@yahoo.com> wrote in message
news:Xns938EC943CA7F0An...@207.46.248.16...