Re: getImage


Posted by mnemo on November 14, 2000 at 11:27:50:

In Reply to: getImage posted by Damian on November 14, 2000 at 00:04:16:

: Hi all!
: I was hoping you could tell me how to get a
: square region of the screen to a Timage?
: (sort of turbo Pascal's GetImage Procedure)

procedure GetDesktopSquare(Canvas: TCanvas; rc: TRect);

Okie, I have created this little code snippet it will take the part of the screen selected in rc and paint it at 0,0 on the specified canvas.

I hope this helps, Good Luck!


/m

CODE:

procedure GetDesktopSquare(Canvas: TCanvas; rc: TRect);
var
scrDC: hDC;
begin
scrDC := GetDC(GetDesktopWindow());
BitBlt(Canvas.Handle, 0, 0, rc.Right-rc.Left, rc.Bottom-rc.Top,scrDC,rc.Left,rc.Top,SRCCOPY);
ReleaseDC(scrDC, GetDesktopWindow());
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
GetDesktopSquare(Image1.Canvas, Rect(0,0,Image1.Width,Image1.Height));
end;




Related Articles and Replies: