CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2005
    Posts
    23

    Exclamation WMF to CLIPBOARD

    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.

  2. #2
    Join Date
    Feb 2005
    Location
    Normandy in France
    Posts
    4,590

    Re: WMF to CLIPBOARD

    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:
    Code:
    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.

  3. #3
    Join Date
    Apr 2005
    Posts
    23

    Re: WMF to CLIPBOARD

    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.

  4. #4

    Re: WMF to CLIPBOARD

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured