Hide titlebar and themes

8 posts, 0 answers
  1. DDS
    DDS avatar
    5 posts
    Member since:
    Jul 2013

    Posted 09 Jul 2013 Link to this post

    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.
  2. Anton
    Admin
    Anton avatar
    167 posts

    Posted 11 Jul 2013 Link to this post

    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 >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. DDS
    DDS avatar
    5 posts
    Member since:
    Jul 2013

    Posted 12 Jul 2013 Link to this post

    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.
  5. George
    Admin
    George avatar
    500 posts

    Posted 17 Jul 2013 Link to this post

    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 >>
  6. DDS
    DDS avatar
    5 posts
    Member since:
    Jul 2013

    Posted 22 Jul 2013 Link to this post

    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.
  7. George
    Admin
    George avatar
    500 posts

    Posted 25 Jul 2013 Link to this post

    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 >>
  8. DDS
    DDS avatar
    5 posts
    Member since:
    Jul 2013

    Posted 25 Jul 2013 Link to this post

    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.
  9. George
    Admin
    George avatar
    500 posts

    Posted 30 Jul 2013 Link to this post

    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 >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready