Is there a VFP function that does it? Win32API needed?
No VFP built-in function, iirc. There are Win32 API calls to do this. Web search on "Visual Foxpro take screenshot" and you should find a couple of good clues.
On Fri, Oct 28, 2016 at 11:29 AM, Man-wai Chang changmw@gmail.com wrote:
Is there a VFP function that does it? Win32API needed?
-- .~. Might, Courage, Vision. SINCERITY! / v \ 64-bit Ubuntu 9.10 (Linux kernel 2.6.39.3) /( _ )\ http://sites.google.com/site/changmw ^ ^ May the Force and farces be with you!
[excessive quoting removed by server]
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
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:profoxtech-bounces@leafe.com] On Behalf Of Mike Copeland Sent: Friday, October 28, 2016 1:28 PM To: profoxtech@leafe.com 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
I On Fri, Oct 28, 2016 at 11:28 AM, Mike Copeland mike@ggisoft.com wrote:
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.
[...]
f you don't mind pulling GDIPlusX, into your program, you can do something like:
* Screengrab cf http://www.mail-archive.com/profox@leafe.com/msg56529.html If Type("_Screen.ActiveForm") = "O" Do System.App loBmp = _Screen.System.Drawing.Bitmap.Fromscreen(_Screen.ActiveForm.HWnd) loBmp.Save(lcErrDir + "offending_form.png", _Screen.System.Drawing.Imaging.ImageFormat.Png) loBmp.Dispose() lcAttachmentList = lcAttachmentList + CRLF + lcErrDir + "offending_form.png" Endif
As you can see, I stole\W was inspired by a post by Christof Wollenhaupt back in 2008.
Thanks, Dave! That works a lot better than mine!
Mike
Dave Thayer wrote:
I On Fri, Oct 28, 2016 at 11:28 AM, Mike Copeland mike@ggisoft.com wrote:
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.
[...]
f you don't mind pulling GDIPlusX, into your program, you can do something like:
- Screengrab cf http://www.mail-archive.com/profox@leafe.com/msg56529.html If Type("_Screen.ActiveForm") = "O" Do System.App loBmp =
_Screen.System.Drawing.Bitmap.Fromscreen(_Screen.ActiveForm.HWnd) loBmp.Save(lcErrDir + "offending_form.png", _Screen.System.Drawing.Imaging.ImageFormat.Png) loBmp.Dispose() lcAttachmentList = lcAttachmentList + CRLF + lcErrDir + "offending_form.png" Endif
As you can see, I stole\W was inspired by a post by Christof Wollenhaupt back in 2008.
Worked in just a few companies that used Visual Foxpro.
*NONE* of them used this kind of function to help customers report bugs. :)
On Sat, Oct 29, 2016 at 2:21 AM, Mike Copeland mike@ggisoft.com wrote:
Thanks, Dave! That works a lot better than mine!