By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,579 Members | 1,773 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,579 IT Pros & Developers. It's quick & easy.

How do I create an image from my screen

P: n/a
Hi,

I want to create an image that looks exactly the same as the things I see in
my application.
I have an application in which you can create some controls, drag them
anywhere you like.
Now I want to export these controls to an image. The image should reflect
the position of the controls and the controls should look the same in the
picture as they do on the screen.

Is there anyway to do this in Visual Basic.Net 2003?

Thank you,
Steven
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Steven" <St****@discussions.microsoft.com> schrieb:
I want to create an image that looks exactly the same as the things I see
in
my application.
I have an application in which you can create some controls, drag them
anywhere you like.
Now I want to export these controls to an image. The image should reflect
the position of the controls and the controls should look the same in the
picture as they do on the screen.


<URL:http://www.google.com/groups?selm=sQVN4qGXDHA.2000%40cpmsftngxa06.phx.gb l>

<URL:http://dotnet.mvps.org/dotnet/samples/windowsandforms/Screenshot.zip>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2

P: n/a
Stu
Hi,

If you don't mind spending the money I have had good results using this:

http://www.winformreports.co.uk/

Stu

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:O3**************@tk2msftngp13.phx.gbl...
"Steven" <St****@discussions.microsoft.com> schrieb:
I want to create an image that looks exactly the same as the things I see
in
my application.
I have an application in which you can create some controls, drag them
anywhere you like.
Now I want to export these controls to an image. The image should reflect
the position of the controls and the controls should look the same in the
picture as they do on the screen.


<URL:http://www.google.com/groups?selm=sQVN4qGXDHA.2000%40cpmsftngxa06.phx.gb l>

<URL:http://dotnet.mvps.org/dotnet/samples/windowsandforms/Screenshot.zip>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

P: n/a
Hi,
Thank you for your reply.
I tried both methods as described in your links. The first method, drawing
each control separately worked, but with problems. All controls were drawn as
black rectangles.
Probably has to do with the fact that i use user defined controls.
The scond method works. After some editing I can take a screenshot of the
items in my application, as with CTR-PrintScreen
The next challenge I have to face is that my application uses scrollbars. So
I have to take multiple screenshots, after each screenshot scroll to a next
visible area, and afterwards glue these bitmaps together to form one big
bitmap.

I will puzzle some more to try to find this out. Thank you very much for
your help, I'm helped very much.

Steven

"Herfried K. Wagner [MVP]" wrote:
"Steven" <St****@discussions.microsoft.com> schrieb:
I want to create an image that looks exactly the same as the things I see
in
my application.
I have an application in which you can create some controls, drag them
anywhere you like.
Now I want to export these controls to an image. The image should reflect
the position of the controls and the controls should look the same in the
picture as they do on the screen.


<URL:http://www.google.com/groups?selm=sQVN4qGXDHA.2000%40cpmsftngxa06.phx.gb l>

<URL:http://dotnet.mvps.org/dotnet/samples/windowsandforms/Screenshot.zip>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4

P: n/a
Here's code that I use to actually print the form image -- the technique
copies the screen image to a bitmap -- with modification it may work in
your case.

'***
<Conditional("DEBUG")> _
<System.Runtime.InteropServices.DllImport("gdi32.d ll",
EntryPoint:="BitBlt", SetLastError:=True,
CharSet:=Runtime.InteropServices.CharSet.Auto,
CallingConvention:=Runtime.InteropServices.Calling Convention.Winapi)> _
Private Shared Function BitBlt( _
ByVal hdcDest As IntPtr, _
ByVal nXDest As Integer, _
ByVal nYDest As Integer, _
ByVal nWidth As Integer, _
ByVal nHeight As Integer, _
ByVal hdcSrc As IntPtr, _
ByVal nXSrc As Integer, _
ByVal nYSrc As Integer, _
ByVal dwRop As System.Int32) As Long

End Function

#If DEBUG Then
Private memoryimage As Bitmap
#End If

<Conditional("DEBUG")> _
Private Sub CaptureScreen()
Dim mygraphics As Graphics = Me.CreateGraphics()
Dim s As Size = Me.Size
memoryimage = New Bitmap(s.Width, s.Height, mygraphics)
Dim memoryGraphics As Graphics = Graphics.FromImage(memoryimage)
Dim dc1 As IntPtr = mygraphics.GetHdc
Dim dc2 As IntPtr = memoryGraphics.GetHdc
BitBlt(dc2, 0, 0, Me.ClientRectangle.Width, _
Me.ClientRectangle.Height, dc1, 0, 0, 13369376)
mygraphics.ReleaseHdc(dc1)
memoryGraphics.ReleaseHdc(dc2)
End Sub

<Conditional("DEBUG")> _
Private Sub btnPrintForm_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnPrintForm.Click
CaptureScreen()
PrintDocument1.Print()
End Sub

<Conditional("DEBUG")> _
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object,
ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument1.PrintPage
e.Graphics.DrawImage(memoryimage, 0, 0)
End Sub
End Class

---
http://code.box.sk
nemo me impune lacessit

*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.