Hi,
How can i create bitmap of a window form with all its child controls
without showing this form?
1. I am trying to create bitmap image of a window form.
2. I am creating a new instance of Form at runtime.
3. Then adding several controls like Button, RadioButton,Che ckBox etc
to it.
4. Now i want to create bitmap with all controls showing on it which
are added to this form.
I am trying it by Control.DrawToB itmap().But in this way i am not
getting the controls in that bitmap of the form which are added to
it.But when i am showing the form , all controls appears in the
bitmap.But i want such bitmap without showing form or being visible.
How can i make it possible? Kindly reply ASAP. 2 8377
Melisa,
The reason this doesn't work is because without making the form visible,
it doesn't create the child controls (at least, the windows handles for the
child controls).
To get around this, you will have to create the handle for the form, and
then create the handle for each child control in the form. The easiest way
to do this would be to recursively cycle through the controls on the form,
and then all of its controls, etc, etc.
To get the handle, just assign the Handle property of the control to a
dummy variable.
Then, when you call DrawToBitmap, it should turn out just fine.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Melisa" <pr************ *@nagarro.comwr ote in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
Hi,
How can i create bitmap of a window form with all its child controls
without showing this form?
1. I am trying to create bitmap image of a window form.
2. I am creating a new instance of Form at runtime.
3. Then adding several controls like Button, RadioButton,Che ckBox etc
to it.
4. Now i want to create bitmap with all controls showing on it which
are added to this form.
I am trying it by Control.DrawToB itmap().But in this way i am not
getting the controls in that bitmap of the form which are added to
it.But when i am showing the form , all controls appears in the
bitmap.But i want such bitmap without showing form or being visible.
How can i make it possible? Kindly reply ASAP.
Nicholas Paldino [.NET/C# MVP] wrote:
Melisa,
The reason this doesn't work is because without making the form visible,
it doesn't create the child controls (at least, the windows handles for the
child controls).
To get around this, you will have to create the handle for the form, and
then create the handle for each child control in the form. The easiest way
to do this would be to recursively cycle through the controls on the form,
and then all of its controls, etc, etc.
To get the handle, just assign the Handle property of the control to a
dummy variable.
Then, when you call DrawToBitmap, it should turn out just fine.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Melisa" <pr************ *@nagarro.comwr ote in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
Hi,
How can i create bitmap of a window form with all its child controls
without showing this form?
1. I am trying to create bitmap image of a window form.
2. I am creating a new instance of Form at runtime.
3. Then adding several controls like Button, RadioButton,Che ckBox etc
to it.
4. Now i want to create bitmap with all controls showing on it which
are added to this form.
I am trying it by Control.DrawToB itmap().But in this way i am not
getting the controls in that bitmap of the form which are added to
it.But when i am showing the form , all controls appears in the
bitmap.But i want such bitmap without showing form or being visible.
How can i make it possible? Kindly reply ASAP.
Hi Nicholas,
Thanks , for your valuable suggestion. It is working that ways and it
has solved my problem to a great extent.
Still I have a confusion that why it is not working if I call "
Control.CreateC ontrol() " method when we are able to create Handle for
the control by the same method.
Do you have any idea in this regard ?? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Stan Shankman |
last post by:
C# -- Visual Studio.Net – Windows Application
Greetings all,
How do I copy a Form’s image to a bitmap? – And do so before it gets to the screen.
I haven’t been able to find anyone that knows how to do this - - all I want to do is copy a Form’s image to a bitmap. - - In effect,
I want to take a window-shot of a Form, (as opposed to a “screen-shot”) but it must be done before that Form hits the screen.
Anyone? Ideas?
|
by: Bradford |
last post by:
I have an Windows application that displays lots of different colored lines in a Panel by using the Graphics.DrawLine method. The location and length of each line comes from a database query that takes two minutes to complete.
I am using the Panel's Paint event to call my drawing method, which accepts PaintEventArgs as a parameter. The problem is that every time the Window is moved or hidden, it needs to be repainted, which takes a long time...
|
by: Balu Ramachandran |
last post by:
How can I create the Thumbnail view from the form?
In the following approach I tried but Iams facing some limitations to get
the thumbnail image of the form alone.
Plaese any one can help in this regard. It is a serious problem for me.
Thanks!
Approach - I - Bitmap (screen capture method)
=============================================
Can able to create the thumbnail image using Bitmap and BitBlt.
|
by: Tina |
last post by:
I'm in a button clicked event on mainpage.aspx. I want to display a new
webpage that has just my image, which is a jpg. I want the page to be a
..jpg not an aspx so that it will be easy for the user to save to disk.
How can I do this?
Thanks,
T
|
by: Richard Skopal |
last post by:
In .NET Windows forms I can create a metafile using this code:
Graphics grph = aControl.CreateGraphics();
IntPtr ipHDC = grph.GetHdc();
Metafile mf = new Metafile(aImgFilePath, ipHDC, EmfType.EmfOnly);
grph.ReleaseHdc(ipHDC);
grph.Dispose();
grph = Graphics.FromImage(mf);
grph.DrawRectangle(aPen, 10, 10, 100, 120);
grph.Dispose();
| |
by: Rich |
last post by:
Hello,
I want to simulate the dynamic thumbnail display of Windows Explorer (winxp)
on a form or pannel container. If I place a picture box on my container
form/pannel and dimension it to the size of a thumbnail and set the sizemode
to Stretch -- I get one thumbnail. I want to retrieve all the picture files
(jpg, bmp) in a directory into an array list and then display this list as
thumbnails on my form dynamically. So my question is...
|
by: dgk |
last post by:
I'm trying to save the image of a webbrowser control. Not a particular
image being shown on the page, but rather the visible display of the
webbrowser. Using VS2005 I figured that maybe DrawToBitmap would work,
but it appears that the webbrowser doesn't implement it.
So I looked around and found that this code:
Dim g As Graphics
g.CopyFromScreen(Me.wb1.PointToScreen(New Point(0, 0)), New
Point(0, 0), wb1.Size)
|
by: Duracel |
last post by:
Hi,
I've got a routine that fetches a bitmap from a COM server and converts it
into a .NET format bitmap. The original DIB surface is 24 bit. When
blitting this bitmap to a window, the speed is pretty good when the window
is around 1/4 the size of the screen, but if I go maximise the window, it
slows to a crawl (relative crawl). Anyway, I've read some blogs about how
to increase the speed, including using GDI instead of GDI+,...
|
by: akiarea |
last post by:
Hi
Please tell me how to create a bitmap. Draw on it and how to save that bitmap to a bmp file.
I done following : on a button click event.
CDC* pDC = GetDC();
CDC memDC;
CBitmap newbmp;
|
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...
|
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...
| |
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...
|
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...
|
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();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |