
FB II Compiler
PG PRO
Debugging
Memory
System
Mathematics
Resources
Disk I/O
Windows
Controls
Menus
Mouse
Keyboard
Text
Fonts
Drawing
Sound
Clipboard
Printing
Communication
ASM |
DRAWING
Capture screen
Here's how to do it:
- use GETWMGRPORT to get the grafport the desktop lives in
- SETPORT to that port
- start recording your picture, probably with OPENPICTURE
- COPYBITS the entire port on top of the entire port, in _srcCopy mode
- use CLOSEPICTURE to stop recording and save the picture handle
The last three steps are all that USR GETPICT really does inside.
I think I have something to begin with :
LOCAL FN GetScreenPict&
DIM currPort&,wmgrPrt&, rect.8, h&
CALL GETPORT(currPort&)
wmgrPrt&=FN NEWPTR(108) 'reservation m'emoire pour nouveau port
CALL OPENCPORT(wmgrPrt&) 'ouverture du nouveau port
CALL SETPORT(wmgrPrt&) 'activation du nouveau port
CALL SETRECT(rect,0,0,SYSTEM(_scrnWidth),SYSTEM(_scrnHeight))
h&=USR GETPICT(rect)
CALL SETPORT(currPort&)
CALL CLOSECPORT(wmgrPrt&)
err=FN DISPOSPTR(wmgrPrt&)
END FN=h&
WINDOW 1,"Test", (30,60)-(200,100)
h&=FN GetScreenPict&
WINDOW 2,"Show",(10,50)-(700,550)
PICTURE (0,0),h&
DEF DISPOSEH(h&)
DO: UNTIL FN BUTTON
I adapted a long time ago a piece of Pascal code to write to the screen (like zooming rects in the Finder). Using this technique along with your sample
My suggestion is to forget about all that port switching--it's unnecessary.
USR GETPICT will snap whatever's on the screen, regardless of what the current port is set to. The only part played by the current port is this:
1. USR GETPICT uses the coordinate system of the current port;
2. USR GETPICT is confined to the clipping region of the current port.
To work around item 1, you can use the GLOBALTOLOCAL procedure. To work around item 2, you can (temporarily) set the current window's clipping region to cover the entire screen. Here's a demo that displays a little "half-size"
picture of the screen (including desktop & menu bar):
DIM rect.8, pt.4
sWidth = SYSTEM(_scrnWidth)
sHeight = SYSTEM(_scrnHeight)
WINDOW 1,"",(0,0)-(sWidth/2, sHeight/2), _dialogMovable
HANDLEEVENTS 'Let Finder refresh desktop
'Get screen corner in window's local co-ord's:
CALL SETPT(pt, 0, 0)
CALL GLOBALTOLOCAL(pt)
'Define rect as entire screen, in local co-ord's:
CALL SETRECT(rect, pt.h%, pt.v%, pt.h% + sWidth, pt.v%+ sHeight)
'Save window's current clip region:
oldClip& = FN NEWRGN
CALL GETCLIP(oldClip&)
'Set clip region to entire screen:
CALL CLIPRECT(rect)
'Snap entire screen:
h& = USR GETPICT(rect)
'Restore old clip region:
CALL SETCLIP(oldClip&)
CALL DISPOSERGN(oldClip&)
'Draw the little picture:
PICTURE (0,0)-(sWidth/2, sHeight/2), h&
DEF DISPOSEH(h&)
DO
HANDLEEVENTS
UNTIL _false
|