In the Minority (Ken Getz) : Create Screen Dump of a Windows Form:
"Recently, friend Paul Sheriff sent this email:
Remember in VB6 we had the Me.Print and it would print the bitmap of the form? Is there anyway to do that in VB.NET?
I sat on it for a while, knowing that it would be fun to work out, once I got to it. Turns out, in VS 2005, it's really easy. The Control class adds a DrawToBitmap method, so you can create a method like this to do the work:
Public Function GetFormImage(ByVal frm As Form) As Bitmap
Dim bmp As Bitmap
Using g As Graphics = Me.CreateGraphics()
Dim sz As Size = frm.Size
bmp = New Bitmap(sz.Width, sz.Height, g)
frm.DrawToBitmap(bmp, New Rectangle(0, 0, sz.Width, sz.Height))
End Using
Return bmp
End Function
Pass in a form reference, and you've got yourself a bitmap of the form's contents. ..."
Interesting... I can see a couple places where this could help. Think "Support Request" or "Bug Report" function/email/upload.
I hate having to train users to take screen-shots of a given app when requesting help, reporting a bug, etc. So instead build the capture into the app itself, with OS/app version/etc info and upload it all to a web service, published via RSS feed, etc (or email... but email is so 90's... and I have enough crap in my inbox already).
All in all, being able to easily grab a form as a bitmap is pretty cool...
Check out the entire post for the VS2003 version.
Sunday, December 18, 2005
1 comment:
NOTE: Anonymous Commenting has been turned off for a while... The comment spammers are just killing me...
ALL comments are moderated. I will review every comment before it will appear on the blog.
Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...
I reserve, and will use, the right to not approve ANY comment for ANY reason. I will not usually, but if it's off topic, spam (or even close to spam-like), inflammatory, mean, etc, etc, well... then...
Please see my comment policy for more information if you are interested.
Thanks,
Greg
PS. I am proactively moderating comments. Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...
How about making it complete and extending it by giving a function to make a bmp file?
ReplyDeletePublic Sub WriteBMPToFile(ByVal in_BMP as Bitmap, ByVal in_strFullFileName as String)
' Greg supplies code...
End Sub