Foxite.COM Community Weblog

Foxite.COM Community Weblog - free weblog service for the Visual FoxPro Community.
Welcome to Foxite.COM Community Weblog Sign in | Join | Help
in
Home Blogs Forum Photos Forum Archives

VFP IMAGING



Send Images to the Clipboard with GdiPlus-X

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

Published Tuesday, January 09, 2007 1:13 PM by cesarchalom
Filed Under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

frankling said:

Cool.
January 9, 2007 3:01 PM
 

Cesar Chalom said:

Few days ago I posted a solution based on Alexander Golovlev's GPIMAGE GDI+ class showing how to send...
January 29, 2007 9:14 PM
 

LuisMaria said:

Este articulo esta traducido al español en www.PortalFox.com

"Enviar imágenes al portapapeles con GdiPlus-X"
http://www.portalfox.com/article.php?sid=2328

July 11, 2007 9:19 PM

What do you think?

(required) 
(optional)
(required) 

This Blog

Post Calendar

<January 2007>
SuMoTuWeThFrSa
31123456
78910111213
14151617181920
21222324252627
28293031123
45678910

Syndication