Page 1 of 1

copy an image from the Windows clipboard - SOLVED

Posted: Sat Nov 30, 2024 1:27 pm
by MGA
Would it be possible, using a dialog with an image resource, to copy an image from the Windows clipboard?

Re: copy an image from the Windows clipboard

Posted: Sat Nov 30, 2024 5:03 pm
by cmsoft
Prueba este ejemplo, para ver si te sirve:

Code: Select all | Expand

#include "fivewin.ch"

//----------------------------------------------------------------------------//

function Main()

   local aImages, oWnd, oFont, oBrush, oBrw, oImage

   FW_SetUnicode( .t. )
   HB_SETCODEPAGE( "UTF8" ) // Harbour (not xHarbour) to display unicode filenames


   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-15
   DEFINE WINDOW oWnd
   oWnd:SetFont( oFont )

   DEFINE BUTTONBAR oWnd:oBar SIZE 100,32 2007
   SET MESSAGE OF oWnd TO "" 2007

   DEFINE BUTTON OF oWnd:oBar PROMPT "Center"     CENTER ACTION ( oImage:Center(),    oImage:SetFocus() )
   DEFINE BUTTON OF oWnd:oBar PROMPT "Fit Width"  CENTER ACTION ( oImage:FitWidth(),  oImage:SetFocus() )
   DEFINE BUTTON OF oWnd:oBar PROMPT "Fit Height" CENTER ACTION ( oImage:FitHeight(), oImage:SetFocus() )
   DEFINE BUTTON OF oWnd:oBar PROMPT "Fit Rect"   CENTER ACTION ( oImage:FitRect(),   oImage:SetFocus() )
   DEFINE BUTTON OF oWnd:oBar PROMPT "Rotate"     CENTER ACTION ( oImage:Rotate(),    oImage:SetFocus() )
   DEFINE BUTTON OF oWnd:oBar PROMPT "Paste"      CENTER ACTION ( oImage:lCanPaste := .t.,oImage:Paste(),  oImage:SetFocus() )
   DEFINE BUTTON OF oWnd:oBar PROMPT "Copy"       CENTER ACTION ( oImage:CopyToClipBoard(.t.),  oImage:SetFocus() )
   

   @ oWnd:oBar:nHeight,300 XIMAGE oImage SIZE 0,-oWnd:oMsgBar:nHeight ;
      OF oWnd RESOURCE "PINGUINO"

   WITH OBJECT oWnd
      :nWidth     := ScreenWidth()  * 0.6
      :nHeight    := ScreenHeight() * 0.6
   END

   ACTIVATE WINDOW oWnd CENTERED
   RELEASE FONT oFont


return nil
el .rc

Code: Select all | Expand

#ifdef __FLAT__
   1 24 "WindowsXP.Manifest"
#endif

PINGUINO RCDATA "..\bitmaps\pngs\2.png"

Re: copy an image from the Windows clipboard

Posted: Sat Nov 30, 2024 8:00 pm
by karinha
Cuando sea mayor quiero ser como César. jajajajaja.

Gracias César!

Regards, saludos.