<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Wizard Software - All things Delphi (and some PHP) &#187; Code snippet</title>
	<atom:link href="http://wizard-soft.com/blog/category/code-snippet/feed/" rel="self" type="application/rss+xml" />
	<link>http://wizard-soft.com/blog</link>
	<description>Delphi, Pascal, PHP, programming and (Wizard) Software</description>
	<lastBuildDate>Tue, 01 Dec 2009 06:36:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Screen/Desktop grab in Delphi</title>
		<link>http://wizard-soft.com/blog/2009/08/02/screendesktop-grab-in-delphi/</link>
		<comments>http://wizard-soft.com/blog/2009/08/02/screendesktop-grab-in-delphi/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 13:46:49 +0000</pubDate>
		<dc:creator>Softy</dc:creator>
				<category><![CDATA[Code snippet]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[screen grab]]></category>

		<guid isPermaLink="false">http://wizard-soft.com/blog/?p=119</guid>
		<description><![CDATA[Ever wanted to grab all the desktop/screen in Delphi? Right, me too. I spent a lot of time searching around for different options, as usual, google is your friend. Lots of info available on the web but this code snippet works well:
{------------------------------------------------------------------------------}

procedure TfmMain.Grab(bm: TBitMap; gt : GrabType);
var
 DestRect, SourceRect: TRect;
 h: THandle;
 hdcSrc : THandle;
 [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wanted to grab all the desktop/screen in Delphi? Right, me too. I spent a lot of time searching around for different options, as usual, google is your friend. Lots of info available on the web but this code snippet works well:</p>
<pre>{------------------------------------------------------------------------------}

procedure TfmMain.Grab(bm: TBitMap; gt : GrabType);
var
 DestRect, SourceRect: TRect;
 h: THandle;
 hdcSrc : THandle;
 pt : TPoint;
begin
hdcSrc := 0 ;
 case(gt) of
 GTWINDOW, GTCLIENT : h := GetForeGroundWindow;
 GTSCREEN : h := GetDesktopWindow;
 else h := 0;
 end;
 if h &lt;&gt; 0 then
 begin
 try
 if gt = GTCLIENT then
 begin
 hdcSrc := GetDC(h); // use this for ClientRect
 Windows.GetClientRect(h,SourceRect);
 end
 else
 begin
 hdcSrc := GetWindowDC(h);
 GetWindowRect(h, SourceRect);
 end;
 bm.Width  := SourceRect.Right - SourceRect.Left;
 bm.Height := SourceRect.Bottom - SourceRect.Top;
 DestRect := Rect(0, 0, SourceRect.Right - SourceRect.Left, SourceRect.Bottom - SourceRect.Top);
 StretchBlt(bm.Canvas.Handle, 0, 0, bm.Width,
 bm.Height, hdcSrc,
 0,0,SourceRect.Right - SourceRect.Left,
 SourceRect.Bottom - SourceRect.Top,
 SRCCOPY);
 if gt = GTCLIENT then
 begin
 pt.X :=SourceRect.Left;
 pt.Y :=SourceRect.Top;
 // call Windows.ClientToScreen() to translate X and Y
 Windows.ClientToScreen(h, pt);
 // DrawCursor(bm,pt.X, pt.Y);
 end
 //
 else
 begin
 // DrawCursor(bm,SourceRect.Left, SourceRect.Top);
 end;
 finally
 ReleaseDC(0, hdcSrc);
 end;
 end;
end;</pre>
]]></content:encoded>
			<wfw:commentRss>http://wizard-soft.com/blog/2009/08/02/screendesktop-grab-in-delphi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
