Lost Password?


Go Back   CodeCall Programming Forum > Software Development > Pascal/Delphi

Pascal/Delphi Forum for discussing Borland Delphi and Pascal coding techniques, tips and tricks.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-03-2006, 07:29 PM
MrDiaz MrDiaz is offline
Learning Programmer
 
Join Date: Jul 2006
Posts: 65
Rep Power: 9
MrDiaz is on a distinguished road
Default Capture the screen in a TImage

With this code I am going to show you how you can capture your screen using dephi. Let's go step by step.

First we need to insert the component TImage. We are going to use it to paste the screenshot there. Note that you can set up the property stretched to either true or false, with stretch the image will take the whole TImage, this is recommended. You can also try both options and see for yourself the difference.

This is how my application looks like. You can always customize it with whatever you feel comfortable with.

Let's go to the coding now, first we create the procedure that will take care of the screenshot.
Code:
procedure TakeScreenShot (Image : TBitmap);
var
DC : HDC;
begin
DC := GetDC (GetDesktopWindow);
try
Image.Width:= GetDeviceCaps (DC, HORZRES);
Image.Height:= GetDeviceCaps (DC, VERTRES);
BitBlt(Image.Canvas.Handle, 0, 0, Image.Width,
Image.Height,DC, 0, 0, SRCCOPY);
finally
ReleaseDC (GetDesktopWindow, DC);
end;
end;
Take a look that we set up an object named Image, and we especified that it is a bitmap. We will use this to store the image of the screenshot. Then we used
Code:
Image.Width:= GetDeviceCaps (DC, HORZRES);
Image.Height := GetDeviceCaps (DC, VERTRES);
In that code we use the image width and call the GetDeviceCaps that what it does it take the screen width (horizontal) and the Image.Height takes the vertical size of our skin.

And now how do we call this procedure to place the screenshot on our image? We call it like this:
Code:
TakeScreenShot(Image1.Picture.Bitmap);
You can use that anywhere you want, in a button OnClick event, on a timer, etc...

Well that's pretty much it, now go ahead and try the program and make something cool out of it.

Happy Coding!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 12-02-2006, 11:16 AM
ProgMania ProgMania is offline
Newbie
 
Join Date: Nov 2006
Posts: 6
Rep Power: 0
ProgMania is on a distinguished road
Default

Nice tutorial. Thanks. I Only got one "bad" thing, Maybe you should consider posting a sample or an example with the tutorial.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-03-2006, 02:21 PM
dirkfirst dirkfirst is offline
Programming Professional
 
Join Date: May 2006
Posts: 338
Rep Power: 12
dirkfirst is on a distinguished road
Default

The source code would be nice to have.
__________________
DirkFirst
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 12-06-2006, 12:57 PM
TcM's Avatar   
TcM TcM is offline
Code Warrior
 
Join Date: Aug 2006
Location: In a technologic world :p
Posts: 8,332
Rep Power: 68
TcM is a glorious beacon of lightTcM is a glorious beacon of lightTcM is a glorious beacon of lightTcM is a glorious beacon of lightTcM is a glorious beacon of light
Default

Nice I like it alot!! Thanks mate!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Transmitting video capture from server to client (Newbie) MrNobody Visual Basic Programming 30 05-02-2008 05:18 PM
Timer for splash screen verion24 Visual Basic Programming 3 08-01-2007 02:09 AM
capture screen shot from an application during run time engr Visual Basic Programming 1 01-29-2007 04:38 PM
16 " screen techni68 Computer Hardware 5 01-22-2007 11:43 AM
JavaScript:Tutorial, Screen Resolution TcM Javascript 6 12-30-2006 06:45 AM


All times are GMT -5. The time now is 11:24 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 97%

Ads