Solved

screencopy procedure

Posted on 2000-05-14
6
165 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
Industry Leaders: 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Delphi IDE crash without error message ... 7 118
Multiple image collision 13 88
tvirtualstringtree freeze when load too manny images 10 80
migrate this code to work on android 1 29
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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 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