All samples below use the new GdiPlus-X library, from VFPX
http://www.codeplex.com/wiki/view.aspx?projectname=vfpx&title=gdiplusx
** the following code example demonstrates how to send an
** image to the clipboard
** sample totally based on the method "toclipboard" from gpimage gdi+ class
** from alexander golovlev
DO LOCFILE("system.app")
WITH _SCREEN.SYSTEM.drawing
LOCAL lobmp AS xfcbitmap
lobmp = .BITMAP.new(GETPICT())
LOCAL lhbitmap, hbmp, hndl
lhbitmap = lobmp.gethbitmap(.COLOR.lightgray)
#DEFINE err_clipnotopen "cannot open the clipboard"
#DEFINE err_clipnodata "no bitmap data found on the clipboard"
#DEFINE err_clipsetdata "cannot place data on the clipboard"
*-- predefined clipboard formats
#DEFINE cf_bitmap 2
#DEFINE cf_palette 9
#DEFINE obj_bitmap 7
DECLARE LONG openclipboard IN win32api LONG HWND
DECLARE LONG closeclipboard IN win32api
DECLARE LONG emptyclipboard IN win32api
*declare long getclipboarddata in win32api long uformat
DECLARE LONG setclipboarddata IN win32api LONG uformat, LONG HMEM
DECLARE LONG copyimage IN win32api LONG himage, LONG utype, LONG cx, LONG cy, LONG uflags
DECLARE LONG deleteobject IN win32api LONG hobject
hbmp = copyimage(lhbitmap, 0, 0, 0, 0)
deleteobject(lhbitmap)
IF openclipboard(0) != 0
emptyclipboard()
hndl = setclipboarddata(cf_bitmap, hbmp)
closeclipboard()
IF hndl = 0
ERROR err_clipsetdata
ENDIF
ELSE
ERROR err_clipnotopen
ENDIF
ENDWITH
RETURN
Cool.
ReplyDeleteEste articulo esta traducido al español en www.PortalFox.com
ReplyDelete"Enviar imágenes al portapapeles con GdiPlus-X"
http://www.portalfox.com/article.php?sid=2328