How to make chrome-type flaps [closed]

0

I would like to know how I create tabs of type a of Chrome. I thought with TabControl but there is no way to put the button close tab and new tab. How do I do it?

PS: I want to make a standalone for a game that can open more than one tab to play. It is a desktop application. (WindowsForms)

    
asked by anonymous 28.07.2014 / 14:45

1 answer

0

I suggest you study the creation of your own controls, there is a good project in CodeProject for this:

link

In the case of creating and removing tabs, you need to implement the OnClick of a custom control (UserControl or Control) separately (attached to the tabs):

public partial class AddTabButton : UserControl
{
    public AddTabButton()
    {
        InitializeComponent();
    }

    // override on OnPaint ou OnClick para adicionar funcionalidades e efeitos
}

The same applies to removing a tab, you need to create a custom control (UserControl) where it is composed of 2 items: Text and a close button, this button you would probably like to implement your own drawing (in the case a class like CloseTabButton similar to the top).

Itisalsonecessarytocreatethetab'scomposer(whichstoresthetabcollection,controlstheappropriatepositions,etc.).

[Serializable]publicclassCustomTabCompositeGroup:UserControl{IList<CustomTab>tabs=newList<CustomTab>();publicCustomTabCompositeGroup(){}publicvoidAddTab(CustomTabtab){this.tabs.Add(tab);this.OnTabCollectionChanged();//AdicionareventoOnClickaobotão+daguia}privatevoidOnTabCollectionChanged(){for(inti=0;i<tabs.Count;i++){//TODO:posiçãodatab}}protectedoverridevoidOnPaint(PaintEventArgse){base.OnPaint(e);}}

Therestisaboutdrawingonthescreen,basicallyyouoverridetheOnPaintmethodanddrawyourownguide:

[Serializable]publicpartialclassCustomTab:UserControl{protectedoverridevoidOnPaint(PaintEventArgse){//TODO:desenharsuaguiaGraphicsgraphics=e.Graphics;graphics.DrawLine(Pens.Black,newPoint(),newPoint(e.ClipRectangle.Right-1,0));base.OnPaint(e);}}

Themethodsrequiredtodrawthetabarehere: link

Why all this? Well, Windows has its own implementation of the Tabs, if you want to create your own it should follow the same path as Chrome, from the "almost zero".

Note: Creating a custom tab control is an arduous task, especially with functionality similar to Google Chrome where tabs can float over the bar and move to a new window, the Chrome Tabs code is located here is extensive:

link

2105 is the Project Branch

    
28.07.2014 / 20:03