This is a migrated thread and some comments may be shown as answers.

transparent background for Rad ShapedForm

12 Answers 418 Views
ShapedForm
This is a migrated thread and some comments may be shown as answers.
mdanh
Top achievements
Rank 1
mdanh asked on 13 Jan 2010, 05:18 AM
How do I set make my ShapedForm's background color transparent? Setting in in the Visual Studio designer throws exception "Control does not support transparency". I am using an image with rounded corner as the background for the form, so unless the background color is transparent, there will be a small area at the form's corners having the same color as the form's background color, which doesn't look nice.

Thanks

12 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 14 Jan 2010, 12:27 PM
Hi mdanh,

In .NET Windows Forms, the top-level windows do not support transparent colors. Since our ShapedForm is a top-level window (or simply a form), it does not support transparent colors as well.

However, you can set the TransparencyKey property to the value of the BackColor. This will make the background of ShapedForm transparent. You may also need to set the color of the border - it can be set to Transparent:
this.TransparencyKey = this.BackColor;
this.BorderColor = Color.Transparent;

If you have additional questions, feel free to contact me.

All the best,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
mdanh
Top achievements
Rank 1
answered on 14 Jan 2010, 12:52 PM
Thanks, that really helps :)
0
Afraei
Top achievements
Rank 1
answered on 02 Jun 2012, 01:59 PM
Hello Nikolay

Could you please give us a sample project that show a transparent background ShapedForm? I have recently checked your tip by Telerik 2012 Q1 and VS 2010 but unfortunately it didn't work as well as is expected. I created a ShapedForm and set (this.TransparencyKey = this.BackColor) then put a PNG transparent image as the form's background image but the form's background didn't appear in transparent manner.

Your kindly help is very appreciated in advance.
Best Regards
0
Nikolay
Telerik team
answered on 06 Jun 2012, 04:59 PM
Hi Afraei,

Thank you for writing.

I am not quite sure what your image is, but if it has a color that is supposed to become transparent and this color is the same as the BackColor of the ShapedForm, both the ShapedForm and the color of the image should become transparent. I am attaching a sample project which covers this scenario. Note there, that one of the colors of the image is the same as the color of the ShapedForm and when this color is set as a TransparencyKey, the appropriate regions of the form become fully transparent.

I hope this helps.

Kind regards,
Nikolay
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
Afraei
Top achievements
Rank 1
answered on 07 Jun 2012, 12:31 PM
Hello Dear Nikolay

Actually, I want to create a Splash form with a partly transparent PNG image. How can I do this. my PNG image and a sample of desired Splash form are attached.

Thank you again
Regards
0
Nikolay
Telerik team
answered on 07 Jun 2012, 12:40 PM
Hello Afraei,

You should follow the approach that I demonstrated in the attached sample project. It seems that you want the white color to become transparent, so you should set the White color as a BackColor of the ShapedForm and you should also set the TransparencyKey to White.

Regards,
Nikolay
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
Afraei
Top achievements
Rank 1
answered on 07 Jun 2012, 12:59 PM
Thank you for your kindly reply.

I changed backcolor = white and transparencykey = white but as you see in the new attachment it is not like the above JPG attachment.
0
Nikolay
Telerik team
answered on 08 Jun 2012, 12:12 PM
Hello Afraei,

I investigated your PNG image carefully and now I understand that it has a transparent color, but not a white color as I initially thought. So, you do not need to set white colors anywhere. Still, with or without setting a white color, I was not able to reproduce the issue that you have. I even tried the sample application with your image on WindowsXP (based on your desktop background image), but the image was transparent there as well as you can see in the screenshot attached to my response.

Please note that ShapedForm does not do anything special in the context of transparency and the issue should be a general case to the machine where you are trying my sample project. I would suggest that you try your scenario with the standard Microsoft Form and if you succeed in achieving transparency there, please write back so that we can apply the same approach to our ShapedForm.

Kind regards,
Nikolay
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
Afraei
Top achievements
Rank 1
answered on 08 Jun 2012, 01:08 PM
Hello Nikolay

Did you create the form that is in opacity.png by telerik? If so, Actually, I need exactly something like that but i don't know how to set the Telerik's form's property to show transparent parts of image. Could you share us your last sample aplication that creates the form in the Opacity.png?

Regards
0
Nikolay
Telerik team
answered on 08 Jun 2012, 02:01 PM
Hello Afraei,

As I implied in my previous reply, the form that you see is the ShapedForm from my sample project with your image and there is nothing additional to it. Therefore, it seems like the issue where you do not get transparent colors is specific to your system and not to our suite. Once again, I would kindly ask you to try experimenting with the standard Microsoft Form which would act the same as ShapedForm. If you manage to achieve transparency with the standard form, you should have no issues to do the same with our ShapedForm.

For your reference, I am attaching my sample project with your image used in it. I hope this helps.

Greetings,
Nikolay
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
Afraei
Top achievements
Rank 1
answered on 08 Jun 2012, 04:33 PM
Hello Dear Nikolay

Thank you again for your great help.

Now I can see the image as a transparent image. As I understood, when I set BackgroundImageLayout by values other than None or Tile or set DoubleBuffered by True then the transparent form will be appeared non-transparent.

Thank you for your appreciated help.
Regards
0
Nikolay
Telerik team
answered on 12 Jun 2012, 10:45 AM
Hi Afraei,

Thank you for sharing your findings with the community.

I am glad to heat that transparency is achieved on your side as well.

Regards,
Nikolay
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
ShapedForm
Asked by
mdanh
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
mdanh
Top achievements
Rank 1
Afraei
Top achievements
Rank 1
Share this question
or