There was an article in the November 2008 issue of FoxRockx that showed how to 
do it using GDI+. (Who says commenting your code is never helpful? :-) It shows 
how to capture the active form or the entire VFP window and save to the Windows 
desktop.

--

rk
-----Original Message-----
From: ProfoxTech [mailto:[email protected]] On Behalf Of Mike 
Copeland
Sent: Friday, October 28, 2016 1:28 PM
To: [email protected]
Subject: Re: Taking a screenshot of "yourself"

Man-wai Chang wrote:
> Is there a VFP function that does it? Win32API needed?

Here's what I use. It creates a snapshot of the entire screen and saves 
it as "error.emf" which is a bit-map format that compresses extremely well.
Mike
========================
PROCEDURE screensnap
  DECLARE INTEGER GetFocus IN user32
  DECLARE INTEGER ReleaseDC IN user32 INTEGER, INTEGER
  DECLARE INTEGER GetWindowRect IN user32 INTEGER, STRING @
  DECLARE INTEGER GetDeviceCaps IN gdi32 INTEGER, INTEGER
  DECLARE INTEGER CloseEnhMetaFile IN gdi32 INTEGER
  DECLARE INTEGER DeleteEnhMetaFile IN gdi32 INTEGER
  DECLARE INTEGER GetWindowDC IN user32 INTEGER
  DECLARE INTEGER CreateEnhMetaFile IN gdi32 INTEGER, STRING, STRING @, 
STRING
  DECLARE INTEGER BitBlt IN gdi32 INTEGER, INTEGER, INTEGER, INTEGER, 
INTEGER, INTEGER, INTEGER, INTEGER, INTEGER
  hwndsrc= &main..HWND
  hdcsrc = getwindowdc(hwndsrc)
  hsize = getdevicecaps(hdcsrc, 4)*100
  vsize = getdevicecaps(hdcsrc, 6)*100
  hres = getdevicecaps(hdcsrc, 8)
  vres = getdevicecaps(hdcsrc, 10)
  rcsrc = REPLICATE(CHR(0), 16)
  = getwindowrect(hwndsrc, @rcsrc)
  nleftsrc = buf2dword(SUBSTR(rcsrc, 1, 4))
  ntopsrc = buf2dword(SUBSTR(rcsrc, 5, 4))
  nrightsrc = buf2dword(SUBSTR(rcsrc, 9, 4))
  nbotsrc = buf2dword(SUBSTR(rcsrc, 13, 4))
  nrightsrc = nrightsrc-nleftsrc
  nbotsrc = nbotsrc-ntopsrc
  STORE 0 TO nleftsrc, ntopsrc
  nmetaleft = (nleftsrc*hsize)/hres
  nmetatop = (ntopsrc*vsize)/vres
  nmetaright = (nrightsrc*hsize)/hres
  nmetabot = (nbotsrc*vsize)/vres
  rcmeta = 
num2dword(nmetaleft)+num2dword(nmetatop)+num2dword(nmetaright)+num2dword(nmetabot)
  hmetadc = createenhmetafile(hdcsrc, "error.emf", @rcmeta, .NULL.)
  = bitblt(hmetadc, 0, 0, nrightsrc, nbotsrc, hdcsrc, 0, 0, 13369376)
  hmetafile = closeenhmetafile(hmetadc)
  = deleteenhmetafile(hmetafile)
  = releasedc(hwndsrc, hdcsrc)
ENDPROC


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/sn1pr10mb0928bdc2c83da410189ef167d2...@sn1pr10mb0928.namprd10.prod.outlook.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to