I encountered a problem using RadTitleBar with ShapedForm. When docked to the top it coveres window border... makes it look pretty ugly.
So, I found several ways to work around this problem, and as I couldn't find any documentation on how to solve it I thought I'd post what I found for people who encounter the same kind of problem.
Solution #1, simplest
Just make the border to be the same color as your title bar. This is very easy. It works ok, but if the window is on top of another window with similar colors it might be hard to actually see the edges of the window. Here's a sample of what it looks like: http://www.telerik.com/support/kb/article/b454K-ttk-b454T-ckd-b454c-ckd.aspx
Solution #2
simulate border around title bar using padding, background color and Shape
here's a code example:
It sets shape for the current form, then shape for the title bar and uses padding to move title bar slightly and sets background color to show the color (black in this case).
Couple of things to note:
So, I found several ways to work around this problem, and as I couldn't find any documentation on how to solve it I thought I'd post what I found for people who encounter the same kind of problem.
Solution #1, simplest
Just make the border to be the same color as your title bar. This is very easy. It works ok, but if the window is on top of another window with similar colors it might be hard to actually see the edges of the window. Here's a sample of what it looks like: http://www.telerik.com/support/kb/article/b454K-ttk-b454T-ckd-b454c-ckd.aspx
Solution #2
simulate border around title bar using padding, background color and Shape
here's a code example:
public partial class Form1 : ShapedForm |
{ |
public Form1() |
{ |
InitializeComponent(); |
RoundRectShape shape = new RoundRectShape( 5 ); |
shape.DeserializeProperties( "5, False, True, False, True" ); |
this.Shape = shape; |
int borderSize = 1; |
RootRadElement titleRoot = this.radTitleBar1.RootElement; |
titleRoot.Padding = new Padding( borderSize, borderSize, 50, 0 ); |
titleRoot.BackColor = Color.Black; |
RadElement rootChild = titleRoot.Children[0]; |
rootChild.Margin = new Padding( 0, 0, borderSize, 0 ); |
rootChild.Shape = shape; |
} |
} |
It sets shape for the current form, then shape for the title bar and uses padding to move title bar slightly and sets background color to show the color (black in this case).
Couple of things to note:
- Setting right padding on the title root element has no effect (I have 50 and it acts like it's 0). To overcome that I set right padding on the 1st child of the title bar.
- I use deserialize properties to set rounder corners only for top left/right corners. I "borrowed" the idea from the QSF source code. It's not documented anywhere it seems.... how many more hidden gems are there in rad framework?
- If you want to use status bar... well, don't, it's hard to get it to work.
- I tried padding the form instead of the title bar, but it didn't work as well.
- Why does this have to be so hard? Why not just create a special ChromeForm class in addition to ShapedForm that would have title bar (or ribbon), with borders, with status bar, all taken care of? It feels too much like I'm hacking, just the way I hack with CSS...
Well, hope this is helpful.