473,796 Members | 2,652 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 3370
You should be able to create a new bitmap the size of the form and use
myform.CreateGr aphics 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.Creat eGraphics()

Dim s As Size = ChildForm.Clien tSize
Dim ChildFormBitmap As Bitmap
ChildFormBitmap = New Bitmap(s.Width, s.Height)
Dim MemoryGraphics As Graphics = Graphics.FromIm age(ChildFormBi tmap)

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

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

MyGraphics.Rele aseHdc(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.CreateGr aphics 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.Creat eGraphics()

Dim s As Size = ChildForm.Clien tSize
Dim ChildFormBitmap As Bitmap
ChildFormBitmap = New Bitmap(s.Width, s.Height)
Dim MemoryGraphics As Graphics = Graphics.FromIm age(ChildFormBi tmap)

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

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

MyGraphics.Rele aseHdc(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.CreateGr aphics 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.Creat eGraphics()

Dim s As Size = ChildForm.Clien tSize
Dim ChildFormBitmap As Bitmap
ChildFormBitmap = New Bitmap(s.Width, s.Height)
Dim MemoryGraphics As Graphics = Graphics.FromIm age(ChildFormBi tmap)

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

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

MyGraphics.Rele aseHdc(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.CreateGr aphics 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
5056
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 form record. In each page of the tab control, there are three buttons: Add, Update, Delete. Any of these buttons will open another, smaller form to add, update or delete the related data record. Originally, I had placed the smaller form such...
3
6965
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 ChildForm(); this.AddOwnedForm (child);
8
4939
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, System.EventArgs e) { MessageBox.Show("keyboard button pressed!"); } Following is the code to load the frmTestBaby
2
1633
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 truncation in its area, i got couple of textboxs and buttons along with a tab control on the child form.
6
6652
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 it yet, or it displays another form and they hit cancel). In any event, I need to be able to cause that MDI Child form to close. Just sticking Me.Close in there won't work, generates an error (note however, that on a NON-MDI form this seems to...
0
1180
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 dbgrid.net) and several other controls. Other forms do not have data grids, but are suffering the same problems. If a child form is moved after being loaded and displayed, it looks horrible. The title bar can disapear, and several controls can...
0
1363
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 in my Application entry point: Public Shared Sub Main() 'Explicitly set apartment state to Single Thread Apartment (STA) System.Threading.Thread.CurrentThread.ApartmentState = System.Threading.ApartmentState.STA Dim eh As New MyExceptionHandler()
3
4739
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 ShowDialog method. I am having a similar problem and I found a thread that had the following code in the child form's Load event: Me.Location = New Point(( _ Me.MdiParent.ClientSize.Width - Me.Width) * 0.5,
1
4166
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 case now is when focus on the other form(regular form, not MDI), ProcessCmdKey() doesn't capture keyboard anymore. Which class should I put ProcessCmdKey() in and anything to make it work? Thanks! namespace myNamespace { public class...
0
9673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10449
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10217
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7546
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5568
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.