tag:blogger.com,1999:blog-20718812.post1128377623016603185..comments2023-11-03T17:28:33.550+05:30Comments on DotNetJalps: How to take ScreenShot in C#Jalpesh Vadgamahttp://www.blogger.com/profile/11897824025804539164noreply@blogger.comBlogger16125tag:blogger.com,1999:blog-20718812.post-8235569005286619532012-12-27T23:45:23.214+05:302012-12-27T23:45:23.214+05:30Here is a detailed and structured one for those wh...Here is a detailed and structured one for those who like to copy/paste:<br /><br />http://www.dotnetobject.com/Thread-take-screenshot-in-windows-form-cAsad Ali Maliknoreply@blogger.comtag:blogger.com,1999:blog-20718812.post-50215514122310824362012-10-26T15:16:55.471+05:302012-10-26T15:16:55.471+05:30Really useful...Thanks.Really useful...Thanks.Giribabunoreply@blogger.comtag:blogger.com,1999:blog-20718812.post-83316295694737750622012-06-21T16:31:30.886+05:302012-06-21T16:31:30.886+05:30how can i take screenshots and save it in pictureb...how can i take screenshots and save it in pictureboxsandhyanoreply@blogger.comtag:blogger.com,1999:blog-20718812.post-16058093826319947792012-02-12T00:05:01.653+05:302012-02-12T00:05:01.653+05:30The using pattern is a lot better than having to m...The using pattern is a lot better than having to manually call Dispose because Dispose is guaranteed to be called when you leave the scope. <br /><br />Consider the following example:<br /><br />Graphics G = Graphigs.FromImage(bitmap)<br />...<br />some error condition occurs<br />throw new SomeException();<br />...<br />g.Dispose();<br /><br />The graphics object doesn't get disposed unless you wrap the code in a try-finally block which is a lot less elegant than just wrapping the code in a using block.pgtipssternoreply@blogger.comtag:blogger.com,1999:blog-20718812.post-84865344821101152092011-04-24T07:37:56.041+05:302011-04-24T07:37:56.041+05:30Awesome tips on how to take screenshot in c#. Extr...Awesome tips on how to take screenshot in c#. Extremely detailed and quite good recommendations. Appreciate itRachat de credithttp://www.7rachat-credits.comnoreply@blogger.comtag:blogger.com,1999:blog-20718812.post-25753465743142407222010-12-17T18:41:09.990+05:302010-12-17T18:41:09.990+05:30There is a difference: If your code in "...&q...There is a difference: If your code in "..." throws an exception and this exception is caught in one of the calling methods your 'g' will not be disposed immediately.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-20718812.post-52656615989989131212010-09-13T21:12:04.656+05:302010-09-13T21:12:04.656+05:30@Anonymous - There is not specific difference. In ...@Anonymous - There is not specific difference. In using object will be dispose automatically and method you suggested will explicitly call dispose method. So there will not be much difference.Jalpesh Vadgamahttps://www.blogger.com/profile/11897824025804539164noreply@blogger.comtag:blogger.com,1999:blog-20718812.post-29213310893449352922010-09-13T19:22:19.549+05:302010-09-13T19:22:19.549+05:30Why is
using(Graphics g = Graphics.FromImage(bitm...Why is <br />using(Graphics g = Graphics.FromImage(bitmap)) <br />{<br /> ...<br />} <br /><br />better than <br /><br />Graphics g = Graphics.FromImage(bitmap);<br />...<br />g.Dispose();<br /><br />I'd really be interested in a profound answer.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-20718812.post-78314340345918662672010-06-09T03:09:33.763+05:302010-06-09T03:09:33.763+05:30The using statement is the correct answer. The Gar...The using statement is the correct answer. The Garbage collector may take minutes, hours, days depending on you application to come by and close and dispose the connection. If this code would be called in a loop it could cause some memory leak issues as well as having poor performance. Managed code does not mean you can just write any old junk and the environment will clean up your mess. It is always better to write it correctly the first time and avoid issues later.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-20718812.post-46821951848423787602009-09-18T00:15:12.364+05:302009-09-18T00:15:12.364+05:30I would also like to point out that:
using(...)
{...I would also like to point out that:<br /><br />using(...)<br />{<br />}<br /><br />should be used for IDisposable types, otherwise they are not cleared by GC.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-20718812.post-84018521169808789962009-04-01T21:23:00.000+05:302009-04-01T21:23:00.000+05:30Hello!Is it possible to get a screenshot of a wind...Hello!<BR/>Is it possible to get a screenshot of a window that is not on the top, i.e. if it is partially hided by another window, without bringing it to the top?<BR/>Thanx<BR/>TJAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-20718812.post-56187235690140701922009-02-24T08:49:00.000+05:302009-02-24T08:49:00.000+05:30You sir, just got 'told'You sir, just got 'told'Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-20718812.post-21096283750694398662008-11-15T15:47:00.000+05:302008-11-15T15:47:00.000+05:30I'm not paranoid and the last time I used C++ was ...I'm not paranoid and the last time I used C++ was when I was in college. I have over 5 years of solid experience in C# and .NET. It's not because you're writing in managed code that you can't leak resources. I'm not talking about leaking memory, which is handled by the garbage collector (but can still occur), but about leaking Win32-handles. Why do you think the IDisposable-interface and the using-construct exist? So you could release a handle (Graphics-object, file handle, ...) deterministically.<BR/><BR/>I suggest you don't slit your wrists and read up on it. Here's a recent discussion about the IDisposable-interface: http://stackoverflow.com/questions/254969/dealing-with-net-idisposable-objectsTommy Carlierhttps://www.blogger.com/profile/00487440070088105656noreply@blogger.comtag:blogger.com,1999:blog-20718812.post-35969499512593977922008-11-01T15:08:00.000+05:302008-11-01T15:08:00.000+05:30The "Leak Handles" version is funny. Like the guy ...The "Leak Handles" version is funny. Like the guy is a paranoid c++ freak from 10 years back. If that code was required to avoid leaks, I would slit my wrists right now and get the pain of programming with memory management of my chest right now.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-20718812.post-81973158109525651042008-04-30T07:03:00.000+05:302008-04-30T07:03:00.000+05:30Leak handles? This is managed code, why would you ...Leak handles? This is managed code, why would you think that?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-20718812.post-37227324918135204912007-08-31T17:06:00.000+05:302007-08-31T17:06:00.000+05:30Your code will leak handles. You should really dis...Your code will leak handles. You should really dispose the Graphics-object and the Bitmap at the end. Here's an alternative version:<BR/><BR/>Rectangle bounds = Screen.GetBounds(Point.Empty);<BR/>using(Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))<BR/>{<BR/> using(Graphics g = Graphics.FromImage(bitmap))<BR/> {<BR/> g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);<BR/> }<BR/> bitmap.Save("test.jpg", ImageFormat.Jpeg);<BR/>}Anonymousnoreply@blogger.com