How Does Clipboard Viewer Get Its Info On Visio Clipboard Contents?

A

Al Koch

Hello,

I am trying to obtain information about data that is placed on the clipboard. For my testing I am using Visio Office Pro 2003 SP1
to copy a symbol from to place data on the clipboard and my examples here are based on that.

I have tried to see what sort of data might be made available (at least by Visio) by code such as:

COleDataObject dataClipboard;
dataClipboard.AttachClipboard();
if (ClipboardEnhMetafileEnabled() && dataClipboard.IsDataAvailable(CF_ENHMETAFILE)) {
STGMEDIUM stgMetafile;
if (dataClipboard.GetData(CF_ENHMETAFILE, &stgMetafile)) {
ENHMETAHEADER EnhMetaHeader;
::GetEnhMetaFileHeader((HENHMETAFILE)stgMetafile.hEnhMetaFile,sizeof(EnhMetaHeader),&EnhMetaHeader);
TCHAR szDesc[16384];
::GetEnhMetaFileDescription((HENHMETAFILE)stgMetafile.hEnhMetaFile,16384,szDesc);
}
}

I first copy a Visio symbol to the clipboard so this places a Metafile on the clipboard. Then the above code is called when my test
app does a Paste. The Paste calls the above code but szDesc which is loaded by ::GetEnhMetaFileDescription() is always empty and I
can't see any useful info in the EnhMetaHeader which is loaded by ::GetEnhMetaFileHeader().

From the above, I would just conclude that Visio simply doesn't supply any "descriptive" info to the clipboard about the Metafile
being placed there except that if I use the Windows Clipboard Viewer app and save the clipboard contents as a *.CLP file I can
examine that file with a hex editor and I see "descriptive" strings such as "Visio 11.0".

My more general question is how does the Clipboard Viewer obtain such data (i.e., "Visio 11.0") and my more specific question is how
can I get info (to allow identifucation of the Visio symbol copied to the clipboard) on Visio symbols placed on the clipboard?

Thank you
Al Koch
(e-mail address removed)
 
B

bnk

What are you going to do with such a "descriptive string" if you get
one?
That is, what is the "primary" problem you are trying to solve?
 
A

Al Koch

What are you going to do with such a "descriptive string" if you get
one?
That is, what is the "primary" problem you are trying to solve?

I need to keep track of the "origin/source" of items that are pasted into my app. So, using Visio as a test "source" case, I'd like
to be able to detect that a Symbol pasted came 1) from Visio and 2) even better, that it was Visio "pre-defined" symbol "XXX".

I realize that if Visio doesn't "mark" a "pre-defined" symbol when it's placed on the clipboard with any sort of designator that I
won't be able to track #2 above, but the fact that the Clipboard Viewer is able to wrire to a *.CLP file strings like "Visio 11.0"
suggests that at least the app is identified in the Cluipboard data (at least in the case of Visio). I expected that that info
would be found in either the Header or Desc as I described but I can't see any such data there. Do you know how Clipboard Viewer is
getting this info ("Visio 11.0") and/or how I can determine the "origin/source" of items that are copied to the Clipboard (or at
least, that it was from Visio)?

Thank you
Al Koch
(e-mail address removed)
 
B

bnk

When Visio copies a shape, it copies the data in many different formats
at once; those include text, emf, some others, and native visio
formats. You can enumerate all formats currently available in the
clipboard, and detect if native Visio format is there...

You could use EnumClipboardFormats API function to enumerate available
formats, calling GetClipboardFormatName for each one; if the format
name is "Visio 11.0 Shapes", you got it.
Based on your code, I suggst that you are using WinAPI/C++:

OpenClipboard(NULL);

UINT format = EnumClipboardFormats(0);
while (format != 0)
{
char name[MAX_PATH] = "";
GetClipboardFormatName(format, name, MAX_PATH);

if (0 == lstrcmp(name, "Visio 11.0 Shapes"))
MessageBox(NULL, "Visio shapes are there!", "Test", 0);

format = EnumClipboardFormats(format);
}
 
A

Al Koch

When Visio copies a shape, it copies the data in many different formats
at once; those include text, emf, some others, and native visio
formats. You can enumerate all formats currently available in the
clipboard, and detect if native Visio format is there...

You could use EnumClipboardFormats API function to enumerate available
formats, calling GetClipboardFormatName for each one; if the format
name is "Visio 11.0 Shapes", you got it.
Based on your code, I suggst that you are using WinAPI/C++:

OpenClipboard(NULL);

UINT format = EnumClipboardFormats(0);
while (format != 0)
{
char name[MAX_PATH] = "";
GetClipboardFormatName(format, name, MAX_PATH);

if (0 == lstrcmp(name, "Visio 11.0 Shapes"))
MessageBox(NULL, "Visio shapes are there!", "Test", 0);

format = EnumClipboardFormats(format);
}
Thanks for the help on this one.

Al Koch
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top