Solved

screencopy procedure

Posted on 2000-05-14
6
163 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 30 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

831 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