I was wondering if someone can help me in finding a way to create a
semi-transparent or transparent panel in netcf? For example if i have
a background image on my main form and i want to add a panel with a
button over my form, so the panel would be semi -transparent showing
the form's background image?
Thanks
--
Regards,
Christian Resma Helle
http://christian-helle.blogspot.com
"mrabie" <mustaf...@gmail.com> wrote in message
news:0e01165a-b326-4f7d...@s8g2000prg.googlegroups.com...
Sorry for the typo
--
Regards,
Christian Resma Helle
http://christian-helle.blogspot.com
"Christian Resma Helle" <xtia...@gmail.com> wrote in message
news:eMWgeTdU...@TK2MSFTNGP02.phx.gbl...
Hi
thanks for the info, what if i want to create my own custom class,
where do i start looking to know how can i override the OnPaint class
to paint with a semi or transparent color?
What I did was to create an interface called IFormBackground that has a
property exposing the BackgroundImage of a form. I then created a custom
control that inherits from Panel, where I overridden the OnPaintBackground
of this control. In my OnPaintBackground I get the Parent control as
IFormBackground, if I get a NULL back then it means that the parent has no
background image coz it doesn't implement IFormBackground. Once I get my
IFormBackground instance, I draw part of the background image that my
control is on top of.
This would give you a so called transparent control effect. Here's the code
in C#
------------------
CODE START
------------------
namespace TransparentPanelSample
{
interface IFormBackground
{
Image BackgroundImage { get; }
}
class TransparentPanel : Panel
{
protected override void OnPaintBackground(PaintEventArgs e)
{
IFormBackground form = Parent as IFormBackground;
if (form == null) {
base.OnPaintBackground(e);
return;
}
e.Graphics.DrawImage(
form.BackgroundImage,
0,
0,
Bounds,
GraphicsUnit.Pixel);
}
}
class MainForm : Form, IFormBackground
{
Bitmap bmp;
TransparentPanel panel;
Button button;
public MainForm()
{
bmp = new Bitmap(
Assembly.GetExecutingAssembly().GetManifestResourceStream(
"TransparentPanelSample.background.jpg"));
panel = new TransparentPanel();
panel.Bounds = new Rectangle(20, 20, 200, 280);
panel.Visible = true;
Controls.Add(panel);
button = new Button();
button.Text = "Button1";
button.Bounds = new Rectangle(50, 50, 70, 30);
button.Visible = true;
panel.Controls.Add(button);
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.DrawImage(bmp, 0, 0);
}
public Image BackgroundImage
{
get { return bmp; }
}
}
}
---------------
CODE END
---------------
I hope this helps...
--
Regards,
Christian Resma Helle
http://christian-helle.blogspot.com
"mrabie" <mustaf...@gmail.com> wrote in message
news:4049547a-e39a-41cd...@v67g2000hse.googlegroups.com...
Hey Christian
thank you so much for the code sample it was really helpful i really
appreciate it