IMPORTANT:
All samples below use the new GDIPlus-X library, that is still in ALPHA version, but is already stable and reliable to do the majority of GDI+ tasks. Download the latest stable release from Codeplex:
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