Page 1 of 1

MetaFile to ClipBoard

Posted: Thu Aug 30, 2007 11:17 am
by yury
hi everyone,

Is possible copy the content of metafile to clipboard of Windows ?

regards

Posted: Fri Aug 31, 2007 12:11 am
by Antonio Linares
Yuri,

Yes, the Windows clipboard supports metafiles by default. Please add this method to FWH Class TClipboard:

Code: Select all

#define CF_ENHMETAFILE      14

METHOD SetMetaFile( oMetaFile ) CLASS TClipBoard

   local lResult := .f.

   if ::Open()
      EmptyClipboard()
      lResult = SetClipboardData( CF_ENHMETAFILE, oMetaFile:hMeta )
      lResult := ::Close() .and. lResult
   endif

return lResult

Posted: Fri Aug 31, 2007 2:30 pm
by yury
Hi Antonio,

thanks for your suport...

Folowing your instructions, i add the method SetMetaFile() on TClipBoard class...

By suposition, i created another method, GetMetaFile():

Code: Select all

method GetMetaFile()

   local hMetaFile := 0

   if ::Open()
      hMetaFile = GetClpData( CF_ENHMETAFILE )
      ::Close()
   endif

return hMetaFile

For test it, I changed my RPreview function this way:

Code: Select all

oMeta1:bRClicked := {|nRow,nCol| SelMeta(oMeta1) }



static Function SelMeta(oMeta)

local oClp:=TClipBoard():New( CF_ENHMETAFILE )

oClp:SetMetaFile( oMeta )

MSGINFO( oClp:IsEmpty() )  => returns .T. ????? 

MSGINFO( oClp:GetMetaFile() ) => returns nil ?????

return nil

Doesn´t work . Is the code correct ?


Gracias Antonio

saludos

Posted: Fri Aug 31, 2007 4:26 pm
by Antonio Linares
Yuri,

Method IsEmpty() has to be modified this way:

Code: Select all

METHOD IsEmpty() CLASS TClipboard

   local uValue

   if ::Open()
      do case
         case ::nFormat == CF_TEXT
              return Empty( GetClpData( CF_TEXT ) )
              
         case ::nFormat == CF_BITMAP
              return GetClpData( CF_BITMAP ) == 0
              
         case ::nFormat == CF_ENHMETAFILE
              return GetClpData( CF_ENHMETAFILE ) == 0
      endcase                                  
      ::Close()
   endif

return .T.

Posted: Sat Sep 01, 2007 3:52 pm
by yury
hi Antonio,

Now the method IsEmpty() is ok !

thank you !

saludos