Hi to all.

I need to create a custom control which does the following:


- It should contain a first, fixed image.
- It should manage a second image, which will change programmatically.
- It should display the second image on top of the first one, updating it in
response to user events; the second image will of course have a transparent
background.
- The second image should be accessible outside the control, and wil be used
for printing on some paper forms which are, as you probably guessed, the
same as the first image; this is the reason for having two separate images.


I'm trying to develop this, but I'm quite confused about the various
System.Drawing classes and which Windows Forms control is the best to use as
my control's base class. I don't thoroughly understand the process of
painting a control, and the relationships between an Image, a Drawing object
and the control.

My initial guess was to use a PictureBox, set its BackGroundImage property
to the fixed image and use the Image property for my drawing... but I don't
know how to do manual drawing this way.

Is this a good approach, or there is a better one?

Also, I know very little about printing with Windows Forms. What do I need
for printing? An Image? A Graphics object? What else?

Can someone please help?


Thanks


Massimo

Re: Two-layered image control by Bryan

Bryan
Tue Apr 17 19:10:51 CDT 2007

Use the PrintDocument class to print from Windows Forms.

If you use the Image property for your drawing, create a variable with a
data type of one of the Image subclasses (like Bitmap). Then, pass that
variable to the static method Graphics.FromImage() to get an instance of
the Graphics class.

Use the Graphics class's draw methods which will write their output to
the Image variable.

--
Bryan Phillips
MCSD, MCDBA, MCSE
Blog: http://bphillips76.spaces.live.com
Web Site: http://www.composablesystems.net



"Massimo" <barone@mclink.it> wrote in message
news:uufkgPTgHHA.392@TK2MSFTNGP06.phx.gbl:

> Hi to all.
>
> I need to create a custom control which does the following:
>
>
> - It should contain a first, fixed image.
> - It should manage a second image, which will change programmatically.
> - It should display the second image on top of the first one, updating it in
> response to user events; the second image will of course have a transparent
> background.
> - The second image should be accessible outside the control, and wil be used
> for printing on some paper forms which are, as you probably guessed, the
> same as the first image; this is the reason for having two separate images.
>
>
> I'm trying to develop this, but I'm quite confused about the various
> System.Drawing classes and which Windows Forms control is the best to use as
> my control's base class. I don't thoroughly understand the process of
> painting a control, and the relationships between an Image, a Drawing object
> and the control.
>
> My initial guess was to use a PictureBox, set its BackGroundImage property
> to the fixed image and use the Image property for my drawing... but I don't
> know how to do manual drawing this way.
>
> Is this a good approach, or there is a better one?
>
> Also, I know very little about printing with Windows Forms. What do I need
> for printing? An Image? A Graphics object? What else?
>
> Can someone please help?
>
>
> Thanks
>
>
> Massimo


Re: Two-layered image control by Massimo

Massimo
Tue Apr 17 19:59:47 CDT 2007

"Bryan Phillips" <bphillips@nospam.spamcop.net.spammenot> ha scritto nel
messaggio news:uJYxj4UgHHA.4156@TK2MSFTNGP02.phx.gbl...

> Use the PrintDocument class to print from Windows Forms.
>
> If you use the Image property for your drawing, create a variable with a
> data type of one of the Image subclasses (like Bitmap). Then, pass that
> variable to the static method Graphics.FromImage() to get an instance of
> the Graphics class.
>
> Use the Graphics class's draw methods which will write their output to the
> Image variable.

Ok, thanks for your help.

Do you think creating this control from a PictureBox base class and using
the BackGroundImage and Image properties can be a good strategy? Maybe it's
better to derive directly from Control (or UserControl, what's the
difference anyway?) and directly draw on the control's surface?


Massimo