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

RadShapedForm with round corner and shadows

8 Answers 613 Views
ShapedForm
This is a migrated thread and some comments may be shown as answers.
mdanh
Top achievements
Rank 1
mdanh asked on 10 May 2010, 09:35 AM
Hi

I posted previously with no reply

I have a RadShapedForm having a custom background image set. The background image contains a gradient color theme (blue). How do I make the form have round corner? I can't find an option to set that. Putting the round corner in the background image together with setting TransparencyKey works in some cases, but it's hard to find a value for TransparencyKey that works all on machines as my gradient background color may be rendered differently on different machines.

Also, how do I make the RadShapedForm have shadows around the border, just like the standard .NET Windows forms?

8 Answers, 1 is accepted

Sort by
0
Accepted
Deyan
Telerik team
answered on 13 May 2010, 10:16 AM
Hello mdanh,

The ShapeForm has a Shape property which can be set to define the shape of the form. Take a look at this code snippet:

public Form1()
{
    InitializeComponent();
    this.Shape = new RoundRectShape(10);  
}

This will round the edges of the form by using a radius of 10 pixels.

You can set a shadow to the form by adding the CS_DROPSHADOW style:

protected override CreateParams CreateParams
        {
            get
            {
                CreateParams cp = base.CreateParams;
                cp.ClassStyle |= 0x20000;
                return cp;
            }
        }

Note that this style is supported as of Windows XP and later versions of Windows.

I hope this helps.

Regards,
Deyan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
mdanh
Top achievements
Rank 1
answered on 14 May 2010, 03:48 AM
Thanks so much for the code snippet. The code to set the form's round corner works well.

Just one thing about the code to set the shadows.  The code works well in most circumstances. However, in cases when one shadowed radShapedForm appears as 'modal' (e.g. via ShowDialog) on top of another shadowed RadShapedForm, the shadow disappears when I click on the parent form. It will appear again when the modal radShapedForm has focus.

Any ideas how to improve this?
0
Deyan
Telerik team
answered on 14 May 2010, 01:46 PM
Hello mdanh,

This is the default Windows behavior - modal dialogs do not have shadows. In our case, the shadow support comes from the base Windows Forms implementation. In other words, we do not have any impact on this behavior.
 
Greetings,
Deyan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
mdanh
Top achievements
Rank 1
answered on 24 May 2010, 08:47 AM
Hi

I have found a minor issue. Currently I dragged a RoundRectShape from the toolbox, then, from the designer, set the Shape property of the form to that RoundRectShape. This works for a while, but after I make some other modifications to the Shaped form in the designer, Visual Studio would automatically remove the Shape properly, and the form would have square corner. This does not happen if the shape is set from code.

I am also using your code snippet to set the shadows for the same form. I am running VS2008.

Any ideas?
0
Accepted
Deyan
Telerik team
answered on 27 May 2010, 03:31 PM
Hi mdanh,

Could you please give us some further details on the case? In fact, there is no RoundRectShape component part in our suite that is registered with the Visual Studio's Toolbox.

The workaround that you have found is valid and you can use with without any concerns.

Regards,
Deyan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
mdanh
Top achievements
Rank 1
answered on 01 Jun 2010, 10:24 AM
Hi

Sorry for the misleading mentioning of roundrectshape on toolbox. I was referring to the non-visible component list below the Visual Studio designer.

But my issue is still valid. Here is a simple VS2008 solution that demonstrate this: http://www.mediafire.com/?ojjxg3mrz2n

1. Currently the form has no round corner. Set a round corner by opening form1.vb in the designer, select RoundRectShape from the dropdown box for the Shape property of the form.

2.  A RoundRectShape1 component will appear in the designer. The form should show round corner in the designer. Run it and everything seems ok (round corner with shadows)

3. Now click on the flag (which is a custom control) in the middle of the form and change some properies, e.g. DefaultImage.

4. Run the solution.

5. Repeat step 3-4 a few times. After a while, the RoundRectShape1 is no longer visible in the designer. Once this happens, the round rect shape will be lost upon the next change in the designer!

I have checked the custom control source code for any possible conflict but can't find any.

Thanks for any hints
0
Accepted
Deyan
Telerik team
answered on 04 Jun 2010, 02:33 PM
Hi mdanh,

Thank you for writing back.

I have been able to reproduce the issue. I would like to inform you that we have logged it in our Issue Tracking System and it will be addressed on one of our next releases.

Currently, I would suggest setting the shape programmatically as a workaround. Your Telerik points have been updated for the report.

Thanks for your time.

Greetings,
Deyan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
mdanh
Top achievements
Rank 1
answered on 05 Jun 2010, 04:18 PM
Thanks. I will set it from code for the time being. Look forward to the bug being fixed in next release.
Tags
ShapedForm
Asked by
mdanh
Top achievements
Rank 1
Answers by
Deyan
Telerik team
mdanh
Top achievements
Rank 1
Share this question
or