Click here to Skip to main content
15,909,205 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everybody,
I am developing a windows application, in that I have a mdi parent and i set a background image for that parent.I have many mdi child forms. so now I want to make the background of a mdi child to transparent, I tried to give the back color and transparent key for that mdi child as same color, but not working, when i remove the mdi parent property of that it is working fine.

So please give me any solution for this.

Thanks in advance.
Posted
Updated 14-May-11 1:50am
v2
Comments
[no name] 14-May-11 7:50am    
Post your code we will guide you where you did the mistake.

Add the following code to your childform ,

<pre> protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x00000020;//WS_EX_TRANSPARENT
return cp;
}
}</pre>
 
Share this answer
 
if you faced any painting problem add the following code in the child form

C#
protected override CreateParams CreateParams
            {
                  get
                  {
                        CreateParams cp = base.CreateParams;
                        cp.ExStyle |= 0x00000020;//WS_EX_TRANSPARENT
                        return cp;
                  }


C#
private int opacity1;
        public int Opacity1
        {
            get { return opacity1; }
            set
            {
            opacity1 = value;
            Rectangle rc = new Rectangle(this.Location, this.Size);
            Parent.Invalidate(rc, true);
            }
        }

C#
protected override void OnPaintBackground(PaintEventArgs e)
        {
            Color bk = Color.FromArgb(Opacity1, this.BackColor);
            e.Graphics.FillRectangle(new SolidBrush(bk), e.ClipRectangle);
        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900