home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / os / mswindo / programm / misc / 4718 < prev    next >
Encoding:
Text File  |  1993-01-07  |  1.8 KB  |  46 lines

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