How to draw a button like the Close Button ?

Hello,
I'm using a JFrame as an undecorated Frame.
Now I'm trying to add a JButton to close the frame.and I want a button that looks like the current system frame CloseButton.
How Can I get the specified UI to draw my JButton?
Or does exist a way to add the system buttons (minimize, maximmize, close) ?
Thanks

horfee wrote:
I said I'm using undecorated frame : it implies i'm already using setUndecorated(true);
So I'm not kidding... Right !NO KIDDING, but what you are now asking for is a decorated frame, so setUndecorated(false) will give you what you want.
But if it's just 3 independent buttons you want, then just capture the image and make the buttons and place them where you want them. It's really as simple as that.

Similar Messages

  • All of a sudden my Firefox brower will not open correctly. It keeps telling me that it is trying to restore the previous session, but it doesnt' matter if I press the Restore button or the Close button to try again, it will not work. How can I fix this?

    After I hit the Close button and try to reopen it tells me that Firefox is currently already running and to either close it or restart my computer. Which I did, and it didn't do anything. Also, when I press the restore button, it will not restore, it just sits there. Please help, I hate Internet Explorer and I don't want to use it longer than I need to.

    It is possible that there is a problem with the files sessionstore.js and sessionstore.bak in the Firefox Profile Folder.
    Delete the files sessionstore.js [2] and sessionstore.bak in the Firefox Profile Folder.
    * Help > Troubleshooting Information > Profile Directory: Open Containing Folder
    * http://kb.mozillazine.org/Profile_folder_-_Firefox
    If you see files sessionstore-##.js with a number in the left part of the name like sessionstore-1.js then delete those as well.
    Deleting sessionstore.js will cause App Tabs and Tab Groups and open and closed (undo) tabs to get lost, so you will have to create them again (make a note or bookmark them).
    See also:
    * [1] http://kb.mozillazine.org/Session_Restore
    * [2] http://kb.mozillazine.org/sessionstore.js

  • Why are all of the toolbar buttons (like the photo button) grayed out in my project?

    How can I get to the pictures in my iphoto library if this button doesn't work? imovie11 9.0.8

    I'm assuming you are working on a Trailer in iMovie (not a standard project). Unfortunately, the templates accept video only - not photos or stills. That's why the Photo Browser is greyed out when you are working with Trailers.
    A way around this is to convert the Trailer to a standard project. Then you will be able to add photos/stills, and perform other edits as desired.
    To convert the Trailer, select "File > Convert to Project" from the menu. Before doing this, it's best to duplicate the Trailer so that all your original edits are intact in the Trailer format. To duplicate, while in Project Library view, click on the Trailer name then select "File > Duplicate Project" from the menu. Use the duplicate to do the conversion.
    Duplicating won't use up much extra space on the hard drive. Projects reference the clips in the associated Event (or Events) - the clips are not copied. The project file also keeps track of titles, transitions, effects, voiceovers, music, edits you've made and so forth - these are text based and use little space.
    John

  • How to create a button like the one pictured here

    How would I create a button like the print button below?
    I was thinking actually make it two separate buttons placed next to each other. The print button obviously would just be a modified boolean, that's easy. But the drop down is a bit harder. I figure I could customize a drop down but because I haven't been able to play around with it in LabVIEW (don't have it at home) I'm not sure if you can modify the alignment of the box that actually drops down etc. Is the drop down box location and look something you can modify within the control editor?
    I'm guessing I could also use .net correct? But I am trying to keep it all with just control modification in LabVIEW if possible. Thanks.
    CLA, LabVIEW Versions 2010-2013
    Solved!
    Go to Solution.
    Attachments:
    buttonexample.PNG ‏6 KB

    for(imstuck),
    I'd use a multicolumn listbox and toggle it's visibility when the user clicks on the button.  I've attached an example:
    ~Simon
    Attachments:
    8-2-2010 2-04-25 PM.png ‏24 KB
    Print Drop Down Snippet.png ‏55 KB
    Print Drop Down.vi ‏29 KB

  • I am using a Microsoft Natural keyboard and when i use the close button on Ver. 5.0 or newer it closes the whole screen not just the active tab is there a fix for this

    I am using a Microsoft Natural 4000 Keyboard
    IF I update to Mozila 5.0 when i use the close button it shuts down the whole browser nut just the active tab
    Is there a workaround for this because I like the close button feature

    Could you try disabling graphics hardware acceleration? (I'm having trouble determining from your "More system information" whether it's enabled or disabled.) Since this feature was added to Firefox, it has gradually improved, but there still are a few glitches.
    You usually need to restart Firefox in order for this to take effect, so save all work first (e.g., mail you are composing, online documents you're editing, etc.).
    orange Firefox button ''or'' classic Tools menu > Options > Advanced
    On the "General" mini-tab, uncheck the box for "Use hardware acceleration when available"
    If you restart Firefox, is the issue resolved?

  • How to restrict closing the tab in tabpane after clicking the close button.

    Hi all,
    Greetings.
    I am implementing a TabPane with different 'user form's in each Tab. And all the tabs are *'closable'*.
    If the user enters some data in the form, and tries to close the tab without saving the form , i need to show a confirm dialogue box that the user should go ahead or not.
    If he clicks cancel, the tab should not close.
    But currently i am searching for a method something like 'setOnClosing' method for tab.
    There is only tab.setOnClosed() method, which will call the event after closing the tab.
    Some thing the code is like below.
    tab.setOnClosed(new EventHandler<javafx.event.Event>() {
         @Override
         public void handle(javafx.event.Event e) {
            // TODO: Actions to be taken on close of tab.
               // Logic to show the confirm dialouge box.
               //  if YES - close the tab
               //  if NO - don't close the tab.
    });But my logic is executing after closing the tab. (ofcourse, as it is on setOnClosed() ;) ). Can anyone tell me how to get control before closing the tab ?
    Thanks in Advance.
    Sai Pradeep Dandem.

    Hi All,
    Finally I managed to get the handler before closing the tab pane. :)
    Though this is a bit weird work around, my requirement is fulfilled at-least.
    Let me explain the workaround I did.
    Tab tab = new Tab(title);
    tab.setClosable(false); // This line of code  makes sure that the “default” close button of the tab is not appeared.
    setClosableButton(tab);Then I am setting the custom close button as a graphic to the label ( Title of the tab), and aligning that graphic position to make an effect, that it is rendered exactly at the position of “Close” button.
    From this Custom Close Button, I am handling the events and if confirmed I am closing the tab manually, by calling the closeTab() method in the TabPaneBehavior class.
    Below is the code that is implemented as per the above logic.
          * Method to set the custom Closable Button to the given tab.
          * @param tab - Tab
         private void setClosableButton(final Tab tab,final boolean closeCheck){
              final StackPane closeBtn = new StackPane(){
                   @Override
                   protected void layoutChildren() {
                        super.layoutChildren();
                        // Setting the orientation of graphic(button) to the right side.
                        ((Label)((LabelSkin)getParent()).getSkinnable()).setStyle("-fx-content-display:right;");
              closeBtn.getStyleClass().setAll(new String[] { "tab-close-button" });
              closeBtn.setStyle("-fx-cursor:hand;");
              closeBtn.setPadding(new Insets(0,7,0,7));
              closeBtn.visibleProperty().bind(tab.selectedProperty());
              final EventHandler<ActionEvent> closeEvent = new EventHandler<ActionEvent>() {
                   @Override
                   public void handle(ActionEvent paramT) {
                        ((TabPaneSkin)TabPaneComponent.this.getSkin()).getBehavior().closeTab(tab);
              // Handler for the close button.
              closeBtn.setOnMouseReleased(new EventHandler<MouseEvent>() {
                   @Override
                   public void handle(MouseEvent paramT) {
                        // My logic to handle the close event or not.
                                    if( logic satisfied){
                             closeEvent.handle(null);
                                    }else{
                                           // Dont close the tab.
              // Showing the close button if the tab is selected.
              tab.selectedProperty().addListener(new ChangeListener<Boolean>() {
                   @Override
                   public void changed(ObservableValue<? extends Boolean> paramObservableValue,Boolean paramT1, Boolean isSelected) {
                        if(isSelected){
                             tab.setGraphic(closeBtn);
                        }else{
                             tab.setGraphic(null);
         }There are some drawbacks in the above code. In practice, it is suggested not to use the classes (*LabelSkin* & TabPaneSkin) that are in com.sun.javafx package. But I couldn’t get a better solution other than using those classes. And another one is I could'nt set the actual graphic for tab, as i am already using that graphic property to show the close button.
    I would like to thank Narayan, for giving some inputs which has helped me to think and get the above solution. :)

  • How can I put the close button in the mainframe of the dialog?

    Hi all,
    I am creating a new dialog and I would like to konw...
    How can I put the close button in the mainframe of the dialog?
    Thanks in advance.
    Best regards,
    Juanma.

    Juanma,
    Usually, a dialog would have an OK and a Cancel button, both can be served as the close button, but if user clicks the ok button (DefaultButtonWidget) to close the dialog, your dialog controller's (if it is based on CDialogController) ApplyDialogFields will get called so you can react to the OK action, otherwise, if user clicks the cancel button (CancelButtonWidget), nothing will happen. The dialog simply is dismissed.
    See BasicDialog SDK sample to see how to add DefaultButtonWidget and CancelButtonWidget to a dialog.
    Thanks!
    lee

  • How to suppress Save As dialog when using the Close button on an editable pdf

    Environment: Windows 7, SDK 9, Adobe Acrobat Pro X, Visual Studio 2010 Professional
    Summary: when a document is opened for editing using automation, edited, then closed using the "Close" button, the confirmation dialog appears, "yes" is selected and then the "Save As" dialog appears.  It should save without the "Save As" dialog in the same way it does were the document opened from Adobe Acrobat directly.  My question is, is there any flag to set which governs whether the "Save As" dialog appears as part of the close document process.  It is behaving as if the document is read-only upon close. (it isn't)
    This is how the document is opened from C++:
    if(SUCCEEDED(hr = ::CoCreateInstance(__uuidof(Adobe9::Acrobat::CAcroAVDoc), 0, CLSCTX_ALL, IID_IUnknown, (void**)&pUnk))){
    hr = OleRun(pUnk);
    if (SUCCEEDED(hr)){
    if (SUCCEEDED(hr = pUnk->QueryInterface(&pAVDoc))){
    hr = pAVDoc->Open((BSTR)CComBSTR(strPath), strDocName, &bRet);
    Even when the plugin is removed from the plug_ins\AcrobatSDK directory, the behaviour is the same.
    Another reproduction is running the BasicIacVC sample, commenting out all lines from gAcroPdDoc->Close(); in InitInstance() and returning TRUE.  If an editable document is opened using the sample, edited then closed using the "X" button, the confirmation dialog is followed by a "Save As" dialog as if it were a read-only document which it is not.
    Any suggestions would be appreciated.
    Regards,
    Evan

    Yes, it does.  (as long as the pdf has been opened via a COM interface)

  • What should I do if the iphoto keeps on saying that "Plz wait for import to complete" when i click the close button but it is not importing photos? How can I close the iPhoto? I try to switch my mac off but it doesn't work. Thanks.

    What should I do if the iphoto keeps on saying that "Plz wait for import to complete" when i click the close button but it is not importing photos? How can I close the iPhoto? I try to switch my mac off but it doesn't work. Thanks.

    You should be able to select Force Quit from the menu beneath the Apple icon in Finder
    and choose to Quit iPhoto from there, without messing up the Mac OS X in the process.
    OS X - Support
    Not sure if rebuilding the iPhoto library would help this issue. However if you had to
    turn off the computer without the correct method (unplug, etc; instead of menu choice)
    the system may have accrued damages and should be checked, maybe repaired by
    use of the Disk Utility in the system. Or restart the computer in Safe Boot mode, then
    run 'repair disk permissions' while it is running in that reduced mode; then restart after.
    •Understanding Safe Mode - tuts+ computer skills tutorial:
    http://computers.tutsplus.com/tutorials/understanding-safe-mode--mac-59897
    •OS X: What is Safe Boot, Safe Mode?
    Suggestions on how to use Safe Mode in article, to resolve issues, may be helpful.
    There likely are other means to rectify troublesome applications, including reinstall.
    Be sure to backup your music, image, video, and other work on an external drive
    or suitable device as a precaution against loss should there be a hard drive failure.
    iPhoto - Mac Apps - Apple Support
    There should be some tips and help information using iPhoto via this tiny Support link.
    Good luck & happy computing!

  • How can I close a tab when the close button is not highlighted?

    I don't know how to close a tab without the x in the upper corner. The support page stated I should right click on the tab for the close button but it is not highlighted in my drop down menu.

    What happens if you type or paste <b>about:config</b> in the location bar?

  • I have an iPhone 3GS and it recently started to make a Cicada type of sound when pushing the close button on the top right hand of the phone. Can anybody give me feedback on what this is or how I might be able to fix it?

    I have an iPhone 3GS and it recently started to make a Cicada type of sound when pushing the close button on the top right hand of the phone. Can anybody give me feedback on what this is or how I might be able to fix it?

    It will be replaced with the exact same model. It is not expensive compared to the full retail price of a new phone (without carrier subsidies).
    If you're eligible for an upgrade from your carrier, now might be a good time to consider upgrading to an iPhone 5, though.

  • How to create a jframe which has only the close button

    hi
    i want to create a jframe which hold only the close button on the title bar. just like an JOptionPane.
    hussain52

    Well, if you are in a window's environment and using forte, you can go to sample forms, MDI, and then just highlight and delete what you don't want from the menubar.

  • How to perform action when the close button is pressed?

    i am using a JInternalFrame and i would like to perform some actions before the internal frame closes when i press the close button on the top right corner of the frame.
    i know the first step is:
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    what next? what actionlistener shd i use??
    thx very much

    Your first step is wrong.
    yourInternalFrame.addInternalFrameListener(
         new InternalFrameAdapter(){
      public void internalFrameClosing(InternalFrameEvent e){
        // do part
    });

  • How to disable the close button(Cross) on a dialog

    Hi,
    Is there a way to disable the close button (cross on the right top of the dialog) on a dialog.
    Thank you

    Since your posting in the swing project forum, I assume your talking about JDialog. If so, use JDialog.setDefaultCloseOperation( DO_NOTHING_ON_CLOSE ). Same method exists in JFrame as well, but not in JWindow.

  • Adding Icon and increasing width of tabpages to show the close button in a tabcontrol

    I have this code right now,
    Public Class FSMTabControl
    Inherits TabControl
    #Region "Declarations"
    Private _TextColour As Color = Color.FromArgb(255, 255, 255)
    Private _BackTabColour As Color = Color.FromArgb(54, 54, 54)
    Private _BaseColour As Color = Color.FromArgb(35, 35, 35)
    Private _ActiveColour As Color = Color.FromArgb(47, 47, 47)
    Private _BorderColour As Color = Color.FromArgb(30, 30, 30)
    Private _UpLineColour As Color = Color.FromArgb(0, 160, 199)
    Private _HorizLineColour As Color = Color.FromArgb(23, 119, 151)
    Private CenterSF As New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center}
    #End Region
    #Region "Properties"
    <Category("Colours")> _
    Public Property BorderColour As Color
    Get
    Return _BorderColour
    End Get
    Set(value As Color)
    _BorderColour = value
    End Set
    End Property
    <Category("Colours")> _
    Public Property UpLineColour As Color
    Get
    Return _UpLineColour
    End Get
    Set(value As Color)
    _UpLineColour = value
    End Set
    End Property
    <Category("Colours")> _
    Public Property HorizontalLineColour As Color
    Get
    Return _HorizLineColour
    End Get
    Set(value As Color)
    _HorizLineColour = value
    End Set
    End Property
    <Category("Colours")> _
    Public Property TextColour As Color
    Get
    Return _TextColour
    End Get
    Set(value As Color)
    _TextColour = value
    End Set
    End Property
    <Category("Colours")> _
    Public Property BackTabColour As Color
    Get
    Return _BackTabColour
    End Get
    Set(value As Color)
    _BackTabColour = value
    End Set
    End Property
    <Category("Colours")> _
    Public Property BaseColour As Color
    Get
    Return _BaseColour
    End Get
    Set(value As Color)
    _BaseColour = value
    End Set
    End Property
    <Category("Colours")> _
    Public Property ActiveColour As Color
    Get
    Return _ActiveColour
    End Get
    Set(value As Color)
    _ActiveColour = value
    End Set
    End Property
    Protected Overrides Sub CreateHandle()
    MyBase.CreateHandle()
    Alignment = TabAlignment.Bottom
    End Sub
    #End Region
    #Region "Draw Control"
    Sub New()
    SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
    ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
    DoubleBuffered = True
    Font = New Font("Segoe UI", 10)
    SizeMode = TabSizeMode.FillToRight
    ItemSize = New Size(240, 32)
    End Sub
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
    Dim g = e.Graphics
    With G
    .SmoothingMode = SmoothingMode.HighQuality
    .PixelOffsetMode = PixelOffsetMode.HighQuality
    .TextRenderingHint = TextRenderingHint.ClearTypeGridFit
    .Clear(_BaseColour)
    Try : SelectedTab.BackColor = _BackTabColour : Catch : End Try
    Try : SelectedTab.BorderStyle = BorderStyle.FixedSingle : Catch : End Try
    .DrawRectangle(New Pen(_BorderColour, 2), New Rectangle(0, 0, Width, Height))
    For i = 0 To TabCount - 1
    Dim Base As New Rectangle(New Point(GetTabRect(i).Location.X, GetTabRect(i).Location.Y), New Size(GetTabRect(i).Width, GetTabRect(i).Height))
    Dim BaseSize As New Rectangle(Base.Location, New Size(Base.Width, Base.Height))
    If i = SelectedIndex Then
    .FillRectangle(New SolidBrush(_BaseColour), BaseSize)
    .FillRectangle(New SolidBrush(_ActiveColour), New Rectangle(Base.X + 1, Base.Y - 3, Base.Width, Base.Height + 5))
    .DrawString(TabPages(i).Text, Font, New SolidBrush(_TextColour), New Rectangle(Base.X + 7, Base.Y, Base.Width - 3, Base.Height), CenterSF)
    .DrawLine(New Pen(_HorizLineColour, 2), New Point(Base.X + 3, CInt(Base.Height / 2 + 2)), New Point(Base.X + 9, CInt(Base.Height / 2 + 2)))
    .DrawLine(New Pen(_UpLineColour, 2), New Point(Base.X + 3, Base.Y - 3), New Point(Base.X + 3, Base.Height + 5))
    Else
    .DrawString(TabPages(i).Text, Font, New SolidBrush(_TextColour), BaseSize, CenterSF)
    End If
    Next
    .InterpolationMode = InterpolationMode.HighQualityBicubic
    End With
    End Sub
    Private Declare Auto Function SetParent Lib "user32" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
    Protected CloseButtonCollection As New Dictionary(Of Button, TabPage)
    Private _ShowCloseButtonOnTabs As Boolean = True
    <Browsable(True), DefaultValue(True), Category("Behavior"), Description("Indicates whether a close button should be shown on each TabPage")> _
    Public Property ShowCloseButtonOnTabs() As Boolean
    Get
    Return _ShowCloseButtonOnTabs
    End Get
    Set(ByVal value As Boolean)
    _ShowCloseButtonOnTabs = value
    For Each btn In CloseButtonCollection.Keys
    btn.Visible = _ShowCloseButtonOnTabs
    Next
    RePositionCloseButtons()
    End Set
    End Property
    Protected Overrides Sub OnCreateControl()
    MyBase.OnCreateControl()
    RePositionCloseButtons()
    End Sub
    Protected Overrides Sub OnControlAdded(ByVal e As System.Windows.Forms.ControlEventArgs)
    MyBase.OnControlAdded(e)
    Dim tp As TabPage = DirectCast(e.Control, TabPage)
    Dim rect As Rectangle = Me.GetTabRect(Me.TabPages.IndexOf(tp))
    Dim btn As Button = AddCloseButton(tp)
    btn.Size = New Size(CInt(rect.Height / 2), CInt(rect.Height / 2))
    btn.Location = New Point(rect.X + rect.Width - rect.Height + 11, CInt(rect.Y + 7))
    SetParent(btn.Handle, Me.Handle)
    AddHandler btn.Click, AddressOf OnCloseButtonClick
    CloseButtonCollection.Add(btn, tp)
    End Sub
    Protected Overrides Sub OnControlRemoved(ByVal e As System.Windows.Forms.ControlEventArgs)
    Dim btn As Button = CloseButtonOfTabPage(DirectCast(e.Control, TabPage))
    RemoveHandler btn.Click, AddressOf OnCloseButtonClick
    CloseButtonCollection.Remove(btn)
    SetParent(btn.Handle, Nothing)
    btn.Dispose()
    MyBase.OnControlRemoved(e)
    End Sub
    Protected Overrides Sub OnLayout(ByVal levent As System.Windows.Forms.LayoutEventArgs)
    MyBase.OnLayout(levent)
    RePositionCloseButtons()
    End Sub
    Public Event CloseButtonClick As CancelEventHandler
    Protected Overridable Sub OnCloseButtonClick(ByVal sender As Object, ByVal e As EventArgs)
    If Not DesignMode Then
    Dim btn As Button = DirectCast(sender, Button)
    Dim tp As TabPage = CloseButtonCollection(btn)
    Dim ee As New CancelEventArgs
    RaiseEvent CloseButtonClick(sender, ee)
    If Not ee.Cancel Then
    Me.TabPages.Remove(tp)
    RePositionCloseButtons()
    End If
    End If
    End Sub
    Protected Overridable Function AddCloseButton(ByVal tp As TabPage) As Button
    Dim closeButton As New Button
    With closeButton
    '' TODO: Give a good visual appearance to the Close button, maybe by assigning images etc.
    '' Here I have not used images to keep things simple.
    .Text = "X"
    .FlatStyle = FlatStyle.Flat
    .BackColor = _BaseColour
    .ForeColor = Color.White
    .Font = New Font("Microsoft Sans Serif", 6, FontStyle.Bold)
    End With
    Return closeButton
    End Function
    Public Sub RePositionCloseButtons()
    For Each item In CloseButtonCollection
    RePositionCloseButtons(item.Value)
    Next
    End Sub
    Public Sub RePositionCloseButtons(ByVal tp As TabPage)
    Dim btn As Button = CloseButtonOfTabPage(tp)
    If btn IsNot Nothing Then
    Dim tpIndex As Integer = Me.TabPages.IndexOf(tp)
    If tpIndex >= 0 Then
    Dim rect As Rectangle = Me.GetTabRect(tpIndex)
    If Me.SelectedTab Is tp Then
    btn.BackColor = Color.Red
    btn.Size = New Size(CInt(rect.Height / 2), CInt(rect.Height / 2))
    btn.Location = New Point(rect.X + rect.Width - rect.Height + 11, CInt(rect.Y + 7))
    Else
    btn.BackColor = _BaseColour
    btn.Size = New Size(CInt(rect.Height / 2), CInt(rect.Height / 2))
    btn.Location = New Point(rect.X + rect.Width - rect.Height + 11, CInt(rect.Y + 7))
    End If
    btn.Visible = ShowCloseButtonOnTabs
    btn.BringToFront()
    End If
    End If
    End Sub
    Protected Function CloseButtonOfTabPage(ByVal tp As TabPage) As Button
    Return (From item In CloseButtonCollection Where item.Value Is tp Select item.Key).FirstOrDefault
    End Function
    #End Region
    End Class
    This code shows a perfect tabcontrol as in the picture below,
    I managed to get this code working by combining three other VB themes I found. Right now, I just want to increase the width of the tab so the close button doesn't hides the text. And I want to add a icon to the left of the tab and be able to change it on
    runtime.
    The icons name will be on, off, 1, 2, plus .ico 
    Is it possible ? and is it possible to make the tabs curved at the corner like in chrome.

    Hi,
     I have went through your TabControl class and changed it around a little bit to get something similar to what i think you want.  I made it so that the Tabs are resized with the TabControl itself so that they always fill the width of the TabControl. 
    I also, made the Text of the tabs have its own rectangle which will automatically adjust it`s width according to weather or not the close buttons are shown so the text will never be under the buttons.
     As for the Icons, you could create another small class that inherits from the TabPage base class and add a public property to it for the Icon image.  You would have to use that class to add TabPages and set the Icon property.  Then in the
    TabControl class`s OnPaint overrides sub you would check if the Icon property of the TabPage is set and draw the image if it is.
     I didn`t go that far but, i used the TabPage`s Tag property for the Icon image.  Actually it is just an Image, not an Icon.  So, in the TabControl`s OnPaint overrides sub i check if the TabPage`s Tag property is set to an Image and if it
    is i adjust the Text rectangle to avoid the Image and draw the image.
     I moved the StringFormat to the OnPaint sub and set it to keep the text left aligned so it stayed next to the Image.  You can change it back to the Center if you want.  I also set the StringFormat trimming to EllipsisCharacter so it will
    cut the text off if it is to long to fit between the Image and the Close button.
     You can test it in a new form project first and to check out how it works and what i changed.
    Imports System.ComponentModel
    Imports System.Drawing.Drawing2D
    Imports System.Drawing.Text
    Public Class FSMTabControl
    Inherits TabControl
    #Region "Declarations"
    Private _TextColour As Color = Color.FromArgb(255, 255, 255)
    Private _BackTabColour As Color = Color.FromArgb(54, 54, 54)
    Private _BaseColour As Color = Color.FromArgb(35, 35, 35)
    Private _ActiveColour As Color = Color.FromArgb(47, 47, 47)
    Private _BorderColour As Color = Color.FromArgb(30, 30, 30)
    Private _UpLineColour As Color = Color.FromArgb(0, 160, 199)
    Private _HorizLineColour As Color = Color.FromArgb(23, 119, 151)
    #End Region
    #Region "Properties"
    <Category("Colours")> _
    Public Property BorderColour() As Color
    Get
    Return _BorderColour
    End Get
    Set(ByVal value As Color)
    _BorderColour = value
    End Set
    End Property
    <Category("Colours")> _
    Public Property UpLineColour() As Color
    Get
    Return _UpLineColour
    End Get
    Set(ByVal value As Color)
    _UpLineColour = value
    End Set
    End Property
    <Category("Colours")> _
    Public Property HorizontalLineColour() As Color
    Get
    Return _HorizLineColour
    End Get
    Set(ByVal value As Color)
    _HorizLineColour = value
    End Set
    End Property
    <Category("Colours")> _
    Public Property TextColour() As Color
    Get
    Return _TextColour
    End Get
    Set(ByVal value As Color)
    _TextColour = value
    End Set
    End Property
    <Category("Colours")> _
    Public Property BackTabColour() As Color
    Get
    Return _BackTabColour
    End Get
    Set(ByVal value As Color)
    _BackTabColour = value
    End Set
    End Property
    <Category("Colours")> _
    Public Property BaseColour() As Color
    Get
    Return _BaseColour
    End Get
    Set(ByVal value As Color)
    _BaseColour = value
    End Set
    End Property
    <Category("Colours")> _
    Public Property ActiveColour() As Color
    Get
    Return _ActiveColour
    End Get
    Set(ByVal value As Color)
    _ActiveColour = value
    End Set
    End Property
    Protected Overrides Sub CreateHandle()
    MyBase.CreateHandle()
    Alignment = TabAlignment.Bottom
    End Sub
    #End Region
    #Region "Draw Control"
    Sub New()
    SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
    DoubleBuffered = True
    Font = New Font("Segoe UI", 10)
    SizeMode = TabSizeMode.Fixed
    End Sub
    Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    With e.Graphics
    .SmoothingMode = SmoothingMode.HighQuality
    .PixelOffsetMode = PixelOffsetMode.HighQuality
    .TextRenderingHint = TextRenderingHint.ClearTypeGridFit
    .Clear(_BaseColour)
    Try : SelectedTab.BackColor = _BackTabColour : Catch : End Try
    Try : SelectedTab.BorderStyle = BorderStyle.FixedSingle : Catch : End Try
    .DrawRectangle(New Pen(_BorderColour, 2), New Rectangle(0, 0, Width, Height))
    If Me.Created AndAlso Me.TabCount > 0 Then
    Dim tw As Integer = CInt(Me.ClientSize.Width / Me.TabCount)
    Dim offset As Integer = Me.TabCount
    If Me.ItemSize.Width <> tw - offset Then Me.ItemSize = New Size(tw - offset, 32)
    End If
    Using CenterSF As New StringFormat With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center, .Trimming = StringTrimming.EllipsisCharacter, .FormatFlags = StringFormatFlags.NoWrap}
    For i As Integer = 0 To TabCount - 1
    Dim Base As Rectangle = Me.GetTabRect(i)
    Dim txtrect As New Rectangle(Base.Left, Base.Top, Base.Width, Base.Height)
    Dim img As Image = Nothing
    If Me.TabPages(i).Tag IsNot Nothing Then
    txtrect.X += Base.Height
    txtrect.Width -= Base.Height
    img = DirectCast(Me.TabPages(i).Tag, Image)
    End If
    If ShowCloseButtonOnTabs Then
    txtrect.Width -= Base.Height
    End If
    If i = SelectedIndex Then
    .FillRectangle(New SolidBrush(_BaseColour), Base)
    .FillRectangle(New SolidBrush(_ActiveColour), New Rectangle(Base.X + 1, Base.Y - 3, Base.Width, Base.Height + 4))
    .DrawString(TabPages(i).Text, Font, New SolidBrush(_TextColour), txtrect, CenterSF)
    .DrawLine(New Pen(_HorizLineColour, 2), New Point(Base.X + 3, CInt(Base.Height / 2 + 2)), New Point(Base.X + 9, CInt(Base.Height / 2 + 2)))
    .DrawLine(New Pen(_UpLineColour, 2), New Point(Base.X + 3, Base.Y - 3), New Point(Base.X + 3, Base.Height + 5))
    Else
    .DrawString(TabPages(i).Text, Font, New SolidBrush(_TextColour), txtrect, CenterSF)
    End If
    If img IsNot Nothing Then
    .DrawImage(img, Base.Left + 2, Base.Top + 2, Base.Height - 4, Base.Height - 4)
    End If
    Next
    End Using
    .InterpolationMode = InterpolationMode.HighQualityBicubic
    End With
    End Sub
    Private Declare Auto Function SetParent Lib "user32" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
    Protected CloseButtonCollection As New Dictionary(Of Button, TabPage)
    Private _ShowCloseButtonOnTabs As Boolean = True
    <Browsable(True), DefaultValue(True), Category("Behavior"), Description("Indicates whether a close button should be shown on each TabPage")> _
    Public Property ShowCloseButtonOnTabs() As Boolean
    Get
    Return _ShowCloseButtonOnTabs
    End Get
    Set(ByVal value As Boolean)
    _ShowCloseButtonOnTabs = value
    For Each btn As Button In CloseButtonCollection.Keys
    btn.Visible = _ShowCloseButtonOnTabs
    Next
    RePositionCloseButtons()
    Me.Refresh()
    End Set
    End Property
    Protected Overrides Sub OnCreateControl()
    MyBase.OnCreateControl()
    RePositionCloseButtons()
    End Sub
    Protected Overrides Sub OnControlAdded(ByVal e As System.Windows.Forms.ControlEventArgs)
    MyBase.OnControlAdded(e)
    Dim tp As TabPage = DirectCast(e.Control, TabPage)
    Dim rect As Rectangle = Me.GetTabRect(Me.TabPages.IndexOf(tp))
    Dim btn As Button = AddCloseButton(tp)
    btn.Size = New Size(CInt(rect.Height / 2), CInt(rect.Height / 2))
    btn.Location = New Point(rect.X + rect.Width - rect.Height + 11, CInt(rect.Y + 7))
    SetParent(btn.Handle, Me.Handle)
    AddHandler btn.Click, AddressOf OnCloseButtonClick
    'ResizeTabs()
    CloseButtonCollection.Add(btn, tp)
    End Sub
    Protected Overrides Sub OnControlRemoved(ByVal e As System.Windows.Forms.ControlEventArgs)
    Dim btn As Button = CloseButtonOfTabPage(DirectCast(e.Control, TabPage))
    RemoveHandler btn.Click, AddressOf OnCloseButtonClick
    CloseButtonCollection.Remove(btn)
    SetParent(btn.Handle, Nothing)
    btn.Dispose()
    MyBase.OnControlRemoved(e)
    'ResizeTabs()
    End Sub
    Protected Overrides Sub OnLayout(ByVal levent As System.Windows.Forms.LayoutEventArgs)
    MyBase.OnLayout(levent)
    RePositionCloseButtons()
    End Sub
    Public Event CloseButtonClick As CancelEventHandler
    Protected Overridable Sub OnCloseButtonClick(ByVal sender As Object, ByVal e As EventArgs)
    If Not DesignMode Then
    Dim btn As Button = DirectCast(sender, Button)
    Dim tp As TabPage = CloseButtonCollection(btn)
    Dim ee As New CancelEventArgs
    RaiseEvent CloseButtonClick(sender, ee)
    If Not ee.Cancel Then
    Me.TabPages.Remove(tp)
    RePositionCloseButtons()
    End If
    End If
    End Sub
    Protected Overridable Function AddCloseButton(ByVal tp As TabPage) As Button
    Dim closeButton As New Button
    With closeButton
    '' TODO: Give a good visual appearance to the Close button, maybe by assigning images etc.
    '' Here I have not used images to keep things simple.
    .Text = "X"
    .FlatStyle = FlatStyle.Flat
    .BackColor = _BaseColour
    .ForeColor = Color.White
    .Font = New Font("Microsoft Sans Serif", 6, FontStyle.Bold)
    End With
    Return closeButton
    End Function
    Public Sub RePositionCloseButtons()
    For Each item As KeyValuePair(Of Button, TabPage) In CloseButtonCollection
    RePositionCloseButtons(item.Value)
    Next
    End Sub
    Public Sub RePositionCloseButtons(ByVal tp As TabPage)
    Dim btn As Button = CloseButtonOfTabPage(tp)
    If btn IsNot Nothing Then
    Dim tpIndex As Integer = Me.TabPages.IndexOf(tp)
    If tpIndex >= 0 Then
    Dim rect As Rectangle = Me.GetTabRect(tpIndex)
    If Me.SelectedTab Is tp Then
    btn.BackColor = Color.Red
    btn.Size = New Size(CInt(rect.Height / 2), CInt(rect.Height / 2))
    btn.Location = New Point(rect.Right - rect.Height + 11, CInt(rect.Y + 7))
    Else
    btn.BackColor = _BaseColour
    btn.Size = New Size(CInt(rect.Height / 2), CInt(rect.Height / 2))
    btn.Location = New Point(rect.Right - rect.Height + 11, CInt(rect.Y + 7))
    End If
    btn.Visible = ShowCloseButtonOnTabs
    btn.BringToFront()
    End If
    End If
    End Sub
    Protected Function CloseButtonOfTabPage(ByVal tp As TabPage) As Button
    Return (From item In CloseButtonCollection Where item.Value Is tp Select item.Key).FirstOrDefault
    End Function
    #End Region
    End Class
     In the Form`s code you can set the images for the TabPage icons like this.
    Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.TabPage1.Tag = Image.FromFile("C:\testfolder\img1.png")
    Me.TabPage2.Tag = Image.FromFile("C:\testfolder\img2.png")
    End Sub
    End Class
     Here is an example of what it looks like.
    If you say it can`t be done then i`ll try it
    Thanks :)) I tried you code and it works perfectly.
    Though i don't want the tabs have their width's by the size of form, so i fixed a width,
    If Me.Created AndAlso Me.TabCount > 0 Then
    'Dim tw As Integer = CInt(Me.ClientSize.Width / Me.TabCount)
    'Dim offset As Integer = Me.TabCount
    'If Me.ItemSize.Width <> tw - offset Then Me.ItemSize = New Size(tw - offset, 32)
    Me.ItemSize = New Size(200, 32)
    End If
    Here is the screenshot,
    I just don't know why the arrows (left and right) aren't full. here is a gif,
    Why is that :O Should I paint the arrows as well ?

Maybe you are looking for

  • Has anyone ever received the error code B8007C54?cc=us

    I own a HP Photosmart C8180 All In One printer and when I plug the power cord in the printer tries to connect then gives me an error message of B8007C54.  Please let me know if anyone has ever received this message and what did you do to correct the

  • Taxonomy files can not displayed

    I create a index for a folder files and build a query-based taxonomy.The files can be automatically classified into taxonomy folders.When I use navigation iviews to browse the taxonomy folders ,I can see some links of files that are automatically cla

  • HT4108 VGA Adapter

    If I purchase the Lightning to VGA Adapter for my iPhone5 will I be able to use Netflix on my phone and watch it on my tv or do I need to purchase additional cables?

  • Desktop photo, dock gone

    On our G5 we have 4 users setup. I noticed last night I could not select a picture in iPhoto 6 and apply that as the desktop photo in my wife's user login. I could change the desktop photo in system prefs for the dock though. This characteristic wasn

  • Compiling problem or xp being poo

    i recently reinstalled xp due to my primary hd dying and then the sdk, since the reinstallation i keep getting the cannot resolve symbol error as if the other classes arent found, is it the luvable compiler or xp being poo?