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

Hide titlebar and themes

7 Answers 875 Views
TitleBar
This is a migrated thread and some comments may be shown as answers.
DDS
Top achievements
Rank 1
DDS asked on 09 Jul 2013, 07:42 PM
Hello,
I'm trying to create a dialog form without title bar and use theme ("Windows8"). Shaped form for some reason uses another window background color, and applying theme doesn't change it. I tried to derive my form from RadForm and hide TitleBar with:
this.FormElement.TitleBar.Visibility = ElementVisibility.Collapsed;

Title bar is hidden. But when I apply "Windows8" theme to my application, my dialog has different border, where TitleBar should be. Also bottom border becomes 1px height, and when TitleBar is visible it is same as left and right borders.

How to accomplish desired look from the attached file?

Thank you.

7 Answers, 1 is accepted

Sort by
0
Anton
Telerik team
answered on 12 Jul 2013, 04:39 AM
Hello Dmitry,

Thank you for writing.

RadForm extends the default Microsoft Form in order to achieve theming. However, it does not support the desired behavior, hence the observed glitches. You can use ShapedForm which is entirely our implementation and you can customize it as you need. By default ShapedForm has independent from themes back color (240,240,240), but you can very easily change it with the color that Windows8Theme sets to RadForm - 239,239,239. Consider the following example:
public partial class Form1 : ShapedForm
{
    public Form1()
    {
        InitializeComponent();
        new Windows8Theme();
 
        ThemeResolutionService.ApplicationThemeName = "Windows8";
 
        this.BorderWidth = 4;
        this.BorderColor = Color.FromArgb(86, 157, 229);
        this.BackColor = Color.FromArgb(239, 239, 239);
    }
}

You can read more about the ShapedForm in this documentation article: http://www.telerik.com/help/winforms/forms-and-dialogs-shapedform-getting-started.html

Attached is a sample demo.

I hope this helps.

Regards,
Anton
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
DDS
Top achievements
Rank 1
answered on 12 Jul 2013, 08:34 AM
Thanks for your reply!

But  your approach with usage of ShapedForm would mean that I would have to apply border style from each theme. In some themes borders are curved, in some not.
What is the best way to do that? To get same look and feel of form as RadForm with theme, but without titlebar.
0
George
Telerik team
answered on 17 Jul 2013, 08:17 AM
Hello Dmitry,

Thank you for writing back.

Indeed you will need to set the border style for each theme using ShapedForm. A solution in your case when using RadForm would be to set the maximum height of the title bar to 1 pixel which would hide it and the border will still look normal.
this.FormElement.TitleBar.MaxSize = new Size(0, 1);

Should you have any other questions, do not hesitate to ask.
 
Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
DDS
Top achievements
Rank 1
answered on 22 Jul 2013, 05:57 PM
Thanks for your suggestion!
When I try it, form still doesn't look perfect.

If I use Windows 7 theme, I get attached results. E.g. bottom border is missing gray line. And top border has some color shift on the left and right sides.
0
George
Telerik team
answered on 25 Jul 2013, 10:54 AM
Hello Dmitry,

Thank you for replying.

To show the bottom border you can change the ScaleTransform property of the FormElement's ImageBorder element which should make the border equal to the borders on the left and on the right:
this.FormElement.ImageBorder.ScaleTransform = new SizeF(10,10);

And to to clear the top border's color shift on the left and right sides you can use the following code:
this.FormElement.TitleBar.FillPrimitive.NumberOfColors = 1;
this.FormElement.TitleBar.FillPrimitive.BackColor = this.FormElement.ImageBorder.BackColor;
this.FormElement.TitleBar.BorderPrimitive.Visibility = ElementVisibility.Collapsed;

Hope this helps, if you have any other questions or comments, please let me know.
 
Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
DDS
Top achievements
Rank 1
answered on 25 Jul 2013, 11:15 AM
Hello George,

This doesn't help.
See my attached image.

As I understand your intention you want me to fix form correctly using current theme. But different themes have different styles of form, borders, curves, etc. I need a form that supports all themes and looks same as any standard form, but just without TitleBar.
0
George
Telerik team
answered on 30 Jul 2013, 09:02 AM
Hi Dmitry,

Thank you for replying.

It is not possible to achieve the best effect with every theme with a few lines of code. If you insist on using the RadForm you should consider some border cases and handle them properly. Another option of yours is to use ShapedForm and load the settings from the themes XML directly. From the XML you can get the border color and other things that may be of use for you. Below is an example code: 
public ShapedForm1()
{
    InitializeComponent();
    this.Load += ShapedForm1_Load;
}
 
void ShapedForm1_Load(object sender, EventArgs e)
{
    Theme controlDefaultTheme = ThemeRepository.FindTheme("ControlDefault");
    Theme clonedTheme = (Theme)controlDefaultTheme.Clone();
    clonedTheme.Name = "CustomTheme";
 
    var group = clonedTheme.FindStyleGroup("Telerik.WinControls.UI.RadForm");
 
    foreach (PropertySettingGroup settingGroup in group.PropertySettingGroups)
    {
        if (settingGroup.Selector.Value == "RadFormElement.IsFormActive")
        {
            foreach (PropertySetting property in settingGroup.PropertySettings)
            {
                if (property.Name == "BackColor")
                {
                    this.BorderColor = (Color)property.Value;
                }
            }
        }
 
    }
}

Please keep in mind that there is no unified approach for this scenario, that is why you will have to consider border cases once again and handle them properly. The XML file of the theme should contain everything you need. You can export XML using the Visual Style Builder.

I hope this will be useful.

Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
TitleBar
Asked by
DDS
Top achievements
Rank 1
Answers by
Anton
Telerik team
DDS
Top achievements
Rank 1
George
Telerik team
Share this question
or