Implementing a chrome window

Article Info

Rating: 4

 

Article information

Article relates to

RadControls for WinForms

Created by

Tsvetan Raikov, Telerik

Last modified

September 10, 2008

Last modified by

Tsvetan Raikov, Telerik


 
HOW-TO
Implement a chrome window with RadControls for WinForms

SOLUTION
To implement a chrome window follow the steps below:
  1. Inherit your form from ShapedForm to control the shape, border and background color of the form:

    C# Code:
     
    using System;  
    using System.Windows.Forms;  
    using Telerik.WinControls;  
    using Telerik.WinControls.UI;  
     
     
    public partial class Form1: ShapedForm  
    {  
          public Form9()  
          {  
                this.Shape = new RoundRectShape(5);  
                this.BorderColor = Color.Blue;  
                this.BorderWidth = 2;  
     
     
                InitializeComponent();  
          }  
    }  


    VB Code:

    Imports System 
    Imports System.Windows.Forms 
    Imports Telerik.WinControls 
    Imports Telerik.WinControls.UI 
     
    Public Partial Class Form1 
        Inherits ShapedForm 
        Public Sub New() 
            Me.Shape = New RoundRectShape(5) 
            Me.BorderColor = Color.Blue 
            Me.BorderWidth = 2 
            
            
            InitializeComponent() 
        End Sub 
    End Class 

     
  2. Drop a RadTitleBar control to the form and dock it to the top. If the selected RadTitleBar theme does not have system buttons, drop an ImageList and fill it with three images (minimize, maximize and close). Associate the ImageList with RadTitleBar control or use the Visual Style Builder to style the title bar. NOTE that the Maximize option of the form will work correctly only if the FormBorderStyle, MinimizeBox, MaximizeBox and ControlBox  properties have default values.
     
  3. Run the form.

The end result should be similar to the following:

Comments

  • Mike , Apr 19, 2007

    Could you post a screenshot?

  • chris crowe , Apr 23, 2007

    Screen snap would be usefull to see the effect you are demonstrating.

  • Timothy Lee Russell , May 7, 2007

    You will notice that the chrome of the window is overwritten if you have any controls docked into your form. That is because the ShapedForm's border is drawn inside your form. You need to add some sort of container and dock your controls into it. Then resize the container as necessary when a user resizes the form so that your container control sizes itself to sit within the border. I used the basic Winforms Panel control and added my RibbonBar and DockingManager to it. In Form_Load, I set: panelApplicationContainer.Location = new Point(BORDER_WIDTH, BORDER_WIDTH); In the Form_Resize method, I set: panelApplicationContainer.Size = new Size(new Point(this.Size.Width - BORDER_WIDTH * 2, this.Size.Height - BORDER_WIDTH * 2)); Hope this helps someone. Timothy http://www.anatone.net

  • Med , Aug 19, 2008

    can you post a VB.NET code example please?

  • Telerik Admin , Sep 10, 2008

    VB coded added!

If you'd like to comment on this KB article, please, send us a Support Ticket.
Thank you!

Please Sign In to rate this article.