How to create bitmap of a window form.

  • Thread starter Thread starter Melisa
  • Start date Start date
M

Melisa

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. But it is not visibile on UI.
4. Then adding several controls like Button, RadioButton,CheckBox etc
to it.
5. Now i want to create bitmap with all controls showing on it which
are added to this form.


I am trying it by Control.DrawToBitmap().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.
 
Maybe ControlPaint class located in the System.Windows.Forms namespace
will help you.


Melisa 写é“:
 
You will have some trouble doing this (as you already know!). The
DrawToBitmap method will not draw child TextBox Controls if their Visible
property is set to false. It also has issues with drawing child RichTextBox
Controls. You may have to use a recursive call the the DrawToBitmap method
for each Control in the form, as well as the form itself.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Magician

A man, a plan, a canal.
a palindrome that has gone to s**t.
 
Back
Top