Solved

screencopy procedure

Posted on 2000-05-14
6
166 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: 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

Technology Partners: 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!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

728 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