2

Given the same content in the system clipboard, I run the following snippets:

For C++:

if (OpenClipboard(NULL)) {
  for (int i = 0;;) {
    i = EnumClipboardFormats(i);
    if (i == 0)
      break;
    GetClipboardFormatName(i, buf, sizeof(buf)/sizeof(buf[0]));
    printf("%+09d\t%s\n", i, buf);
  }
  CloseClipboard();
}

For Java (in an Applet):

Toolkit toolkit = Toolkit.getDefaultToolkit();
Clipboard clipboard = toolkit.getSystemClipboard();
for (DataFlavor df : clipboard.getAvailableDataFlavors()) {
  System.out.println(df.getHumanPresentableName() + " " + df.getMimeType());
}

Surprisingly for me, the two return different number of available formats, and those that I get are apparently also different, e.g. a certain custom data format is interpreted as an x-java-image in Java, even though it's definitely not a picture of any kind.

Does anyone know why this is or how I can adjust this behavior? Basically I would like to access data in custom formats through clipboard in Java, but it doesn't seem to work straight away.

UPD: Here is a sample output the two snippets give for the custom data format in question:

C++

+00049654       MDLSK
+00049156       Native
+00049155       OwnerLink
+00000003       OwnerLink
+00000014       OwnerLink

Java

image/x-java-image image/x-java-image; class=java.awt.Image
Qnan
  • 3,714
  • 18
  • 15
  • `GetClipboardFormatName()` does not work on pre-defined formats, only on user-defined formats that are registered with `RegisterClipboardFormat()`. With that said, it might help if you actually show the list of formats that both languages are actually reporting. – Remy Lebeau Jun 11 '13 at 19:44
  • @RemyLebeau thanks for the information! It's good to know, although it does not really affect this particular issue, since even the number of available formats is different, whatever their actual names are. I've added the sampel outputs to the question. – Qnan Jun 13 '13 at 15:27

0 Answers0