Click to See Complete Forum and Search --> : WMF to CLIPBOARD


minagu
April 6th, 2005, 07:07 AM
Hello, i'm having a problem trying to copy a WMF file to the windows clipboard, and i want to ask you if there is any function wich allows to do it directly. Because i've tried to do it from a metafile structure, but it doesn't goes, cause when i use the SetClipboardData function, the image which appears in the clipboard is the left-up corner of the image, and i don't understand it.

Thank you for read my messagge, and i hope your help.

SuperKoko
April 7th, 2005, 06:26 AM
Theorically SetClipboardData, must be called with a handle to a metafile (and not a HGLOBAL containing a metafile structure).

I have not tested it, but it can look like that:

BOOL CopyEnhMetafileToClipboard(HWND hWndOwner,LPCTSTR pszFileName)
{
if (!OpenClipboard(hWndOwner)) return FALSE;
HENHMETAFILE hmf=GetEnhMetafile(pszFileName);
if (hmf==NULL) {CloseClipboard();return FALSE;}
if (!EmptyClipboard()) {CloseClipboard();DeleteEnhMetafile(hmf);return FALSE;}
BOOL r=SetClipboardData(CF_ENHMETAFILE,hmf)!=NULL;
CloseClipboard();
return r;
}


I hope, this will work correctly.

minagu
April 7th, 2005, 01:15 PM
Thankyou SuperKoko, but the problem is thah what i have is a wmf file. From an emf file with a code like what you have wrote before, it could be possible, but what i really need now is to know if there is a c++ function to transform my wmf file to an emf file, cause i've tested that using a program(not c++) which converts my wmf in emf, i can move it to the clipboard from the emf file.

Thankyou.

andytim
April 8th, 2005, 01:12 AM
Hi,
I remember I have found this kind of code before,I think you need use google to search this kind of article.
Regards
Andy
-------------------------------------------------------------------------
XD++ MFC Library V9.0 -- http://www.********.net