Solved

screencopy procedure

Posted on 2000-05-14
6
159 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
Comment Utility
listenning
0
 
LVL 3

Accepted Solution

by:
shenqw earned 30 total points
Comment Utility
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
Comment Utility
Sorry, forgot to release the DC:

//.....
  SrnCanvas.CopyRect(DRect,SrnCanvas,SRect);
  ReleaseDC(0,SrnCanvas.Handle);
  SrnCanvas.Free;
end;
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 6

Expert Comment

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


GL
Mike
0
 
LVL 4

Expert Comment

by:BoRiS
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

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…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now