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

Capture whole child form in VB.Net

P: n/a
I created a child form that is much bigger than the MDI form in VB.Net. I am
trying to capture the whole child form and save as an image or sent to
printer. I tried to use BitBlt to capture the child form but I can only
capture the visible part of the child form whatever you scroll to any part of
the form. I have read the article in site
http://www.fengyuan.com/article/wmprint.html unforturely it is for C++
instead of VB.Net. I tried to use the same way in VB.Net but failed. Is there
a way in VB.Net to capture whole child form including the part that you have
to scroll to to see? Please Help.

Thanks a lot.

Jack
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
You should be able to create a new bitmap the size of the form and use
myform.CreateGraphics to create a graphics object. The graphics object can
then be copied onto the bitmap using bitblt...This should work.

"jxiang" wrote:
I created a child form that is much bigger than the MDI form in VB.Net. I am
trying to capture the whole child form and save as an image or sent to
printer. I tried to use BitBlt to capture the child form but I can only
capture the visible part of the child form whatever you scroll to any part of
the form. I have read the article in site
http://www.fengyuan.com/article/wmprint.html unforturely it is for C++
instead of VB.Net. I tried to use the same way in VB.Net but failed. Is there
a way in VB.Net to capture whole child form including the part that you have
to scroll to to see? Please Help.

Thanks a lot.

Jack

Nov 21 '05 #2

P: n/a
Thanks Dennis, I tried what you suggeted and I still could not capture the
whole child form. My code is as following. I don't know what is wrong with
code. Please help. Thanks again.

Dim MyGraphics As Graphics = ChildForm.CreateGraphics()

Dim s As Size = ChildForm.ClientSize
Dim ChildFormBitmap As Bitmap
ChildFormBitmap = New Bitmap(s.Width, s.Height)
Dim MemoryGraphics As Graphics = Graphics.FromImage(ChildFormBitmap)

Dim dc1 As IntPtr = MyGraphics.GetHdc
Dim dc2 As IntPtr = MemoryGraphics.GetHdc

BitBlt(dc2, 0, 0, s.Width, s.Height, dc1, 0, 0, SRCCOPY)

MyGraphics.ReleaseHdc(dc1)
MemoryGraphics.ReleaseHdc(dc2)

Return ChildFormBitmap

Jack
"Dennis" wrote:
You should be able to create a new bitmap the size of the form and use
myform.CreateGraphics to create a graphics object. The graphics object can
then be copied onto the bitmap using bitblt...This should work.

"jxiang" wrote:
I created a child form that is much bigger than the MDI form in VB.Net. I am
trying to capture the whole child form and save as an image or sent to
printer. I tried to use BitBlt to capture the child form but I can only
capture the visible part of the child form whatever you scroll to any part of
the form. I have read the article in site
http://www.fengyuan.com/article/wmprint.html unforturely it is for C++
instead of VB.Net. I tried to use the same way in VB.Net but failed. Is there
a way in VB.Net to capture whole child form including the part that you have
to scroll to to see? Please Help.

Thanks a lot.

Jack

Nov 21 '05 #3

P: n/a
What size does s result in, i.e., is it the size of your form?

What size does Memory Graphics end up as?

What is copied to you bitmap?
"jxiang" wrote:
Thanks Dennis, I tried what you suggeted and I still could not capture the
whole child form. My code is as following. I don't know what is wrong with
code. Please help. Thanks again.

Dim MyGraphics As Graphics = ChildForm.CreateGraphics()

Dim s As Size = ChildForm.ClientSize
Dim ChildFormBitmap As Bitmap
ChildFormBitmap = New Bitmap(s.Width, s.Height)
Dim MemoryGraphics As Graphics = Graphics.FromImage(ChildFormBitmap)

Dim dc1 As IntPtr = MyGraphics.GetHdc
Dim dc2 As IntPtr = MemoryGraphics.GetHdc

BitBlt(dc2, 0, 0, s.Width, s.Height, dc1, 0, 0, SRCCOPY)

MyGraphics.ReleaseHdc(dc1)
MemoryGraphics.ReleaseHdc(dc2)

Return ChildFormBitmap

Jack
"Dennis" wrote:
You should be able to create a new bitmap the size of the form and use
myform.CreateGraphics to create a graphics object. The graphics object can
then be copied onto the bitmap using bitblt...This should work.

"jxiang" wrote:
I created a child form that is much bigger than the MDI form in VB.Net. I am
trying to capture the whole child form and save as an image or sent to
printer. I tried to use BitBlt to capture the child form but I can only
capture the visible part of the child form whatever you scroll to any part of
the form. I have read the article in site
http://www.fengyuan.com/article/wmprint.html unforturely it is for C++
instead of VB.Net. I tried to use the same way in VB.Net but failed. Is there
a way in VB.Net to capture whole child form including the part that you have
to scroll to to see? Please Help.

Thanks a lot.

Jack

Nov 21 '05 #4

P: n/a
S is the client size of the child form.
Memory Graphics end up with S size.
The code copies child form to bitmap by DC.
The problem is that the DC only capture the visible part of the child form.
It is not a size issue. The child form can be several times bigger than the
screen.

"Dennis" wrote:
What size does s result in, i.e., is it the size of your form?

What size does Memory Graphics end up as?

What is copied to you bitmap?
"jxiang" wrote:
Thanks Dennis, I tried what you suggeted and I still could not capture the
whole child form. My code is as following. I don't know what is wrong with
code. Please help. Thanks again.

Dim MyGraphics As Graphics = ChildForm.CreateGraphics()

Dim s As Size = ChildForm.ClientSize
Dim ChildFormBitmap As Bitmap
ChildFormBitmap = New Bitmap(s.Width, s.Height)
Dim MemoryGraphics As Graphics = Graphics.FromImage(ChildFormBitmap)

Dim dc1 As IntPtr = MyGraphics.GetHdc
Dim dc2 As IntPtr = MemoryGraphics.GetHdc

BitBlt(dc2, 0, 0, s.Width, s.Height, dc1, 0, 0, SRCCOPY)

MyGraphics.ReleaseHdc(dc1)
MemoryGraphics.ReleaseHdc(dc2)

Return ChildFormBitmap

Jack
"Dennis" wrote:
You should be able to create a new bitmap the size of the form and use
myform.CreateGraphics to create a graphics object. The graphics object can
then be copied onto the bitmap using bitblt...This should work.

"jxiang" wrote:

> I created a child form that is much bigger than the MDI form in VB.Net. I am
> trying to capture the whole child form and save as an image or sent to
> printer. I tried to use BitBlt to capture the child form but I can only
> capture the visible part of the child form whatever you scroll to any part of
> the form. I have read the article in site
> http://www.fengyuan.com/article/wmprint.html unforturely it is for C++
> instead of VB.Net. I tried to use the same way in VB.Net but failed. Is there
> a way in VB.Net to capture whole child form including the part that you have
> to scroll to to see? Please Help.
>
> Thanks a lot.
>
> Jack

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.