home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.ms-windows.programmer.misc
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!torn!nott!emr1!jagrant
- From: jagrant@emr1.emr.ca (John Grant)
- Subject: Re: Graphics cut/copy/paste
- Message-ID: <1993Jan7.224948.3738@emr1.emr.ca>
- Organization: Energy, Mines, and Resources, Ottawa
- References: <1993Jan07.200849.9892@eng.umd.edu>
- Date: Thu, 7 Jan 1993 22:49:48 GMT
- Lines: 35
-
- In article <1993Jan07.200849.9892@eng.umd.edu> equine@eng.umd.edu (Melinda L. Gierisch) writes:
- >
- >I am looking for sample code that allows the user to grab a portion of
- >the screen (not window) and copy it to the clipboard or possibly
- >another application. I know that there are commercial software
- >packages that contain this functionality, but we would then need to
- >worry about licensing agreements, etc. when distributing our application.
- >
- >If anyone knows the proper commands/functions to use, has written such
- >a function, or knows of a reference book that contains this
- >information, please let me know.
-
- It's really quite simple. Assuming you have an HBITMAP,
- you just do:
- OpenClipboard(hwnd);
- EmptyClipboard();
- SetClipboardData(CF_BITMAP,hbitmap);
- CloseClipboard();
-
- Remember that Windows can copy the whole screen or current
- window to the clipboard with the PrintScreen and Alt-PrintScreen
- keys. If you want a portion of the screen, find some way to
- select the region (click, drag etc with the mouse) and then
- copy it to a bitmap:
- hdc=GetDC(hwnd);
- hdccompatible=CreateCompatibleDC(hdc);
- hbitmap=CreateCompatibleBitmap(hdc,x,y);
- BitBlt(...)
- I forget the rest, but you get the idea. Also do *not*
- trust the above pseudo-code - look up the functions
- yourself.
- --
- John A. Grant jagrant@emr1.emr.ca
- Airborne Geophysics
- Geological Survey of Canada, Ottawa
-