473,380 Members | 1,121 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,380 software developers and data experts.

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 3350
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
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
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
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
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
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
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
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
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
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.