views:

666

answers:

3

We have a form which displays media items in tab pages of a tab control, and I'm implementing a feature which allows users to 'pop out' the tab pages into their own forms.

However, when I add the media player to a form rather than a TabPage, the background switches from the gradient fill of a tab page to the plain SystemColors.Control background of the parent form. I need to add the the media player to a control which has the same background as a TabControl, but which doesn't display a tab at the top. I tried adding the media player to the TabControl's control collection, but that just throws an exception.

How do I get a control which looks like a TabControl with no tabs? Should I keep trying to add the media player to a TabControl, or should I try to write a Panel with a custom-drawn background? If the latter, how do I make sure that works with all possible themes?

A: 

Try creating your own customer UserControl

Maen
OK.. how do I make that look like a TabControl with no tabs?
Simon
A TabControl without tabs, isn't that just a Panel?
Svish
@Svish: No. A TabControl, even without tabs, has a specific background determined by the user's theme. In the XP default theme, it's a gradient fill with a border and a drop shadow.
Simon
+3  A: 

Thanks to Henk - I eventually went with:

protected override void OnPaintBackground(PaintEventArgs e)
{
    if (TabRenderer.IsSupported && Application.RenderWithVisualStyles)
    {
        TabRenderer.DrawTabPage(pe.Graphics, this.ClientRectangle);
    }
    else
    {
        base.OnPaintBackground(pe);
        ControlPaint.DrawBorder3D(pe.Graphics, this.ClientRectangle, Border3DStyle.Raised);
    }
}
Simon
Make sure your control has background color Transparent, or else you wont get the same looks as the tab control.
mbp