-
Jan 29th, 2010, 03:26 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] Screen capture of a MDI children
All
I am trying to get the screen capture of a MDI children form. Somehow it is just not working.
Does anyone know where i am going where here?
Cheers
Ken
Code:
Private Sub btnScreen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScreen.Click
Dim frmMain As frmParent = Me.MdiParent
For Each ctl As Control In frmMain.MdiChildren
If TypeOf ctl Is frmOverview Then
Dim frm As frmOverview = ctl
Dim MyBMP As New Bitmap(frm.Width, frm.Height)
Dim G As Graphics = Graphics.FromImage(MyBMP)
'copies image data at location of form (top left), width of the form, to get entire form contents
G.CopyFromScreen(New Point(frm.Location.X, frm.Location.Y), New Point(frm.Location.X, frm.Location.Y), New Size(frm.Width, frm.Height))
G.Dispose()
'saves the image
Clipboard.SetImage(MyBMP)
MessageBox.Show("Screen capture success!")
Exit Sub
End If
Next
If you find my thread helpful, please remember to rate me
-
Jan 29th, 2010, 03:59 PM
#2
Re: Screen capture of a MDI children
First thing I'd ask is "how is it not working"? You need to be a bit more descriptive in order for people to help you out.
Is it giving you the message but not setting the image to the clipboard or are you not even get the message, or will it not even compile?
-
Jan 29th, 2010, 04:23 PM
#3
Thread Starter
Frenzied Member
Re: Screen capture of a MDI children
It is not copying the exact dimensions... it is copying abit of the MDI parent too...
If you find my thread helpful, please remember to rate me
-
Jan 29th, 2010, 04:50 PM
#4
Re: Screen capture of a MDI children
OK so that narrows it down to this line :
Code:
G.CopyFromScreen(New Point(frm.Location.X, frm.Location.Y), New Point(frm.Location.X, frm.Location.Y), New Size(frm.Width, frm.Height)
I've never used the copyfromscreen method, but I'd immediately be a bit suspicious that the first two params are identical. Just a quick check suggests that the first should be the source top left position and the second the destination top left position. That suggests to me they shouldn't be identical necessarily.
Is that where your problem lies?
-
Jan 29th, 2010, 05:12 PM
#5
Re: Screen capture of a MDI children
Try this:
Code:
For Each frm As Form In frmMain.MdiChildren
Using bmp As New Bitmap(frm.Width, frm.Height)
frm.DrawToBitmap(bmp, New Rectangle(0, 0, bmp.Width, bmp.Height))
'Now you have the child form image in bmp bitmap, do whatever desired with it
'
End Using
Next
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Jan 29th, 2010, 06:32 PM
#6
Thread Starter
Frenzied Member
Re: Screen capture of a MDI children
That worked a treat! Thanks!
If you find my thread helpful, please remember to rate me
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|