473,507 Members | 9,962 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Capture whole child form in VB.Net

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
4 3357
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
5031
by: Lyn | last post by:
Hi, I hope someone can help. I have a main form which mostly fills the Access window. In the bottom half of this form I have a tab control to display various types of data related to the main...
3
6924
by: Frank T. Clark | last post by:
How do I redirect or capture keydown events in a parent form from a child form? I have a main form which displays another informational form marked "SizableToolWindow". Form child = new...
8
4918
by: CJack | last post by:
hy, I have an mdi application, i create a child form and I want to know when a button is pressed while that child form is loaded. I have this code: private void frmTestBaby_KeyUp(object sender,...
2
1617
by: seash | last post by:
Hi my application is an MDI application , when i call a child form like this objchild = new frm(); objchild.MdiParent = this; objchild.Show(); the child screen in the container gets a...
6
6640
by: Tom | last post by:
Is there ANY easy way to close a MDI Child form in the middle of it's load? For instance, during the Load event I find a need to close the form (for whatever reason - maybe the user isn't ready for...
0
1168
by: Sarah Smith | last post by:
Hello, I've been working on a rather large project that has an MDI form with several child forms. Some of the child forms are rather complicated. They have 1 or 2 data grids (component one true...
0
1345
by: JWA | last post by:
Hi All, How can you capture unhandled exceptions thrown by an MDI child form separate from the entire app? I have an application-wide exception handler to catch crashes by doing the following...
3
4713
by: Zack Sessions | last post by:
I am using VB.NET 2003. I have read the threads concerning the problem where the FormStartPosition of CenterParent is ignored if the form is displayed with the Show method as opposed to the...
1
4146
by: scudsong | last post by:
I override ProcessCmdKey() in my MDI parent form class and have some keyboard shortcut calling method in same class. But I wish to make these hotkeys working in parent/child form and other form. The...
0
7313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7029
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5039
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3190
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1537
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.