Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Tif to clip
Message
 
To
26/11/2020 09:26:28
General information
Forum:
Visual FoxPro
Category:
Pictures and Image processing
Title:
Miscellaneous
Thread ID:
01677286
Message ID:
01677290
Views:
112
This message has been marked as the solution to the initial question of the thread.
*https://forums.codeguru.com/showthread.php?565003-SetClipboardData()-to-Copy-File

*!* typedef struct _DROPFILES {
*!*   DWORD pFiles; 4
*!*   POINT pt;     4+4
*!*   BOOL  fNC;    4
*!*   BOOL  fWide;  4
*!* } DROPFILES, *LPDROPFILES;

*!* typedef struct tagPOINT {
*!*   LONG x;
*!*   LONG y;
*!* } POINT, *PPOINT;

#DEFINE CF_HDROP 15

#Define GMEM_MOVABLE  0x0002
#Define GMEM_ZEROINIT 0x0040
#Define GMEM_SHARE  0x2000


&&  Clipboard Functions
Declare Long OpenClipboard In WIN32API Long HWnd
Declare Long CloseClipboard In WIN32API
Declare Long EmptyClipboard In WIN32API
Declare Long SetClipboardData In WIN32API Long uFormat, Long Hmem
&&  Memory Management Functions
Declare Long GlobalAlloc In WIN32API Long wFlags, Long dwBytes
Declare Long GlobalFree In WIN32API Long Hmem
Declare Long GlobalLock In WIN32API Long Hmem
Declare Long GlobalUnlock In WIN32API Long Hmem
Declare Long RtlMoveMemory In WIN32API As CopyFromStr Long lpDest, String @lpSrc, Long iLen



m.lcFile= "G:\Clients\xfrx\Test\_Images\_3_small.tiff"

* empty DROPFILES structure
lcDropFiles=CHR(20)+CHR(0)+CHR(0)+CHR(0)+;
            CHR(0)+CHR(0)+CHR(0)+CHR(0)+CHR(0)+CHR(0)+CHR(0)+CHR(0)+;
            CHR(1)+CHR(0)+CHR(0)+CHR(0)+;
            CHR(0)+CHR(0)+CHR(0)+CHR(0)
*!* dropfiles->pFiles = sizeof(DROPFILES);
*!* dropfiles->fNC = TRUE;
*!* dropfiles->fWide = FALSE;

            
lnDataLen=LEN(lcDropFiles) + LEN(m.lcFile) + 2

m.hGlobal = GlobalAlloc(GMEM_MOVABLE+GMEM_ZEROINIT+GMEM_SHARE, lnDataLen)
if m.hGlobal>0
   lpDropFiles = GlobalLock(m.hGlobal)
   
   IF NOT lpDropFiles=0
      *!* memcpy(&dropfiles[1], path, strlen(path))
      lcDropFiles=lcDropFiles+m.lcFile+CHR(0)+CHR(0)
      =CopyFromStr(lpDropFiles, @lcDropFiles, lnDataLen)
      =GlobalUnlock(lpDropFiles)
      
      IF NOT OpenClipboard(0) = 0
         IF NOT EmptyClipboard() = 0
            IF NOT SetClipboardData(CF_HDROP, m.hGlobal)=0
               ?"OK"
            ELSE
               ?"Failed"
            ENDIF
         ENDIF
         =CloseClipboard()
      ENDIF

   ENDIF
   =GlobalFree(m.hGlobal)
ENDIF
MartinaJ

>No my teacher, I am trying to read tif from VFP.
>I have already Tif file with 2 pages and want to copy this file onto _clipboard.
>
>I think following codes converts Tif to bmp with 1 page, then bmp is copied to _clipboard.
>I want to know is there any method to bypass bmp file and tif file directly copy to _clipboard with all pages.
>
>Sorry if I am wrong.
>
>
>#Define CF_BITMAP 2
>#Define CF_DIB 8
>#Define IMAGE_BITMAP 0
>#Define LR_LOADFROMFILE 16
>#Define LR_MONOCHROME 0x00000001
>
>Local xpict
>m.xpict="E:\abc.tif"
>
>Local m.oo
>m.oo=Newobject("image")
>m.oo.Picture=m.xpict
>Local lnWidth,lnHeight
>lnWidth=m.oo.Width
>lnHeight=m.oo.Height
>
>nBitmap=0
>hbm=0
>GdipCreateBitmapFromFile(Strconv(m.xpict+0h00,5),@nBitmap)
>GdipCreateHBITMAPFromBitmap(nBitmap,@hbm,0)
>lhBmp = CopyImage(hbm, 0, m.lnWidth, m.lnHeight,0)
>If OpenClipboard(0)!= 0
>	EmptyClipboard()
>	SetClipboardData(CF_BITMAP, lhBmp)
>	CloseClipboard()
>Endif
>ENDPROC
>
>
>
>
>
>
>>Hi,
>>
>> VFP read first page from multipage TIFF always.
>>If you want read another page/view from TIFF file, you must use GDI+ API.
>>
>>MartinaJ
>>
>>>Respected Sir,
>>>
>>>I have a tif file that contains 2 pages.
>>>I am trying to copy it to _clipboard
>>>
>>>So I have these codes
>>>
>>>
>>>Declare Integer Sleep In kernel32 Integer
>>>Declare Integer OpenClipboard In User32 Integer
>>>Declare Integer CloseClipboard In User32
>>>Declare Integer EmptyClipboard In User32
>>>Declare Integer SetClipboardData In User32 Integer,Integer
>>>Declare Integer LoadImage In WIN32API Integer,String,Integer,Integer,Integer,Integer
>>>Declare Integer GetClipboardData In User32 Integer
>>>Declare Integer GdipCreateBitmapFromHBITMAP In GDIPlus.Dll Integer, Integer, Integer @
>>>Declare Integer GdipSaveImageToFile In GDIPlus.Dll Integer,String,String @,String @
>>>Declare Long GdipCreateHBITMAPFromBitmap In GDIPlus.Dll Long nativeImage, Long @, Long
>>>Declare Long GdipCreateBitmapFromFile In GDIPlus.Dll String FileName, Long @nBitmap
>>>Declare Long GdipCreateBitmapFromFile    In GDIPlus.Dll String FileName, Long @nBitmap
>>>Declare Long CopyImage In WIN32API Long hImage, Long, Long, Long , Long
>>>
>>>#Define CF_BITMAP 2
>>>#Define CF_DIB 8
>>>#Define IMAGE_BITMAP 0
>>>#Define LR_LOADFROMFILE 16
>>>#Define LR_MONOCHROME 0x00000001
>>>
>>>Local xpict
>>>m.xpict="E:\abc.tif"
>>>
>>>Local m.oo
>>>m.oo=Newobject("image")
>>>m.oo.Picture=m.xpict
>>>Local lnWidth,lnHeight
>>>lnWidth=m.oo.Width
>>>lnHeight=m.oo.Height
>>>
>>>nBitmap=0
>>>hbm=0
>>>GdipCreateBitmapFromFile(Strconv(m.xpict+0h00,5),@nBitmap)
>>>GdipCreateHBITMAPFromBitmap(nBitmap,@hbm,0)
>>>lhBmp = CopyImage(hbm, 0, m.lnWidth, m.lnHeight,0)
>>>If OpenClipboard(0)!= 0
>>>	EmptyClipboard()
>>>	SetClipboardData(CF_BITMAP, lhBmp)
>>>	CloseClipboard()
>>>Endif
>>>ENDPROC
>>>
>>>
>>>Codes work fine but when I press Ctrl+v in clipboard there is only 1 page instead of 2
>>>It means _clipboard is holding only 1 page.
>>>
>>>How is it possible to copy all pages from tif file to clipboard?
>>>
>>>Attachment has abc.tif and prg.
>>>
>>>Please help
"Navision is evil that needs to be erazed... to the ground"

Jabber: gorila@dione.zcu.cz
Jabber? Jabbim
Previous
Reply
Map
View

Click here to load this message in the networking platform