Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

screencopy procedure

Posted on 2000-05-14
6
Medium Priority
?
170 Views
Last Modified: 2010-04-04
Hi Experts!

I want just to copy a section fo the screen (maybe to the clipboard) so I can copy it to another part of the same screen... I think this a very simple and basic question but so far I dont know what exactly I have to do. Anybody knows how to do it?

best regards,
Manuel López (lopem)
0
Comment
Question by:lopem
6 Comments
 
LVL 3

Expert Comment

by:bryan7
ID: 2809064
listenning
0
 
LVL 3

Accepted Solution

by:
shenqw earned 120 total points
ID: 2809409
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
  SrnCanvas:TCanvas;
  SRect,DRect:TRect;
begin
  SRect.Left:=0;
  SRect.Top:=0;
  SRect.Right:=200;
  SRect.Bottom:=200;
  DRect.Left:=200;
  DRect.Top:=200;
  DRect.Right:=400;
  DRect.Bottom:=400;
  SrnCanvas:=TCanvas.Create;
  SrnCanvas.Handle:=GetDc(0);
  SrnCanvas.CopyRect(DRect,SrnCanvas,SRect);
  SrnCanvas.Free;
end;

end.
0
 
LVL 3

Expert Comment

by:shenqw
ID: 2809435
Sorry, forgot to release the DC:

//.....
  SrnCanvas.CopyRect(DRect,SrnCanvas,SRect);
  ReleaseDC(0,SrnCanvas.Handle);
  SrnCanvas.Free;
end;
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:edey
ID: 2809490
you can also use the bitblt api instead of messing with an extra TCanvas.


GL
Mike
0
 
LVL 4

Expert Comment

by:BoRiS
ID: 2809933
lopem

An application can simulate a press of the PRINTSCREEN key in order to obtain a screen snapshot and save it to the Windows clipboard. To do this, call keybd_event with the bVk parameter set to VK_SNAPSHOT, and the bScan parameter set to 0 for a snapshot of the full screen or set bScan to 1 for a snapshot of the active window.

this will simulate the key press

keybd_event(VK_SNAPSHOT, 0, 0, 0);//this will capture the entire screen

keybd_event(VK_SNAPSHOT, 1, 0, 0);//this will capture the active window

then to tell the system the is is up again

keybd_event(VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0);

you can send this on a button click or any other key you want aswell as example below...

procedure TForm1.FormKeyDown(Sender: TObject....blah blah)
begin
 if Key = VK_F10 then begin
  keybd_event(VK_SNAPSHOT, 0, 0, 0);
  keybd_event(VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0);
 end;
end;

That's it now the capture of the entire screen is sitting on the clipboard...

Later
BoRiS
 
0
 
LVL 3

Author Comment

by:lopem
ID: 2811177
Boris,

Thank you for your ideas... I was in some sort of ethical problem because your answer and shenqw's answer seems to me pretty good. There is no way to share the points of the answer, right? (I gave the points to shenqw because he answered exactly my question)...

Thank you anyway and Im very amazed about the fast and kind response of all experts and not only here, I mean in a general context inside this place. This site is great!

Best regards,
Manuel López (lopem)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question