MetaFile to ClipBoard

Post Reply
yury
Posts: 56
Joined: Wed May 23, 2007 2:01 pm

MetaFile to ClipBoard

Post by yury »

hi everyone,

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

regards
Yury Marcelino Al
yury030575@yahoo.com.br
vimansca@vimansca.com.br
Leme / SP - Brasil
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
yury
Posts: 56
Joined: Wed May 23, 2007 2:01 pm

Post 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
Yury Marcelino Al
yury030575@yahoo.com.br
vimansca@vimansca.com.br
Leme / SP - Brasil
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
yury
Posts: 56
Joined: Wed May 23, 2007 2:01 pm

Post by yury »

hi Antonio,

Now the method IsEmpty() is ok !

thank you !

saludos
Yury Marcelino Al
yury030575@yahoo.com.br
vimansca@vimansca.com.br
Leme / SP - Brasil
Post Reply