# VBForums CodeBank > CodeBank - Visual Basic 6 and earlier >  NewTab: tab control for VB6

## Eduardo-

Download from GitHub.

This is a tab control based on previous control SSTabEx.

This new control keeps backward compatibility with the original SSTab that came with VB6 and is mostly backward compatible also with SSTabEx, although some properties have changed.

It introduces the flat style and several properties related to it.
It also adds many new features not only related to flat style, for example:

Soft tab transitions (see TabTransition property, thanks LeandroA).
Icons from fonts (thanks Shagratt).
Tab dragging to another position (see CanReorderTabs property).
Tabbed Document Interface mode (see TDIMode property).

Since it has now many properties, it is hard to remember how to configure something specific that we like, so it introduces the feature of "Themes". Themes are property presets that primarily define appearance but also some behavior.
They can be stored as a file, optionally in the registry and in the control properties. If offers several themes by default but you can add your own ones.
There is a Themes property that exposes the Themes collection, and a Theme property where you can set one by its name.

Documentation online.






Download from GitHub.

----------


## Eduardo-

Reserved.

----------


## LeandroA

Very good work Eduardo, an excellent final result  :wave:

----------


## SearchingDataOnly

@Eduardo-,

I'm working on a code editor whose interface will emulate VSCode. So I need a lightweight TabCtrl(PageCtrl) similar to VSCode, and I don't know if your new TabControl can emulate VSCode's TabCtrl(PageCtrl).

Also, SSTabEx is too heavy and complex to be considered by me.

*Edit:*
VSCode's TabCtrl(PageCtrl) provides "window splitting" feature, just like a Container-Splitter.

----------


## yokesee

Very good work.
I've used STabEx a lot and this one looks much better.

----------


## ColinE66

> @Eduardo-,
> 
> I'm working on a code editor whose interface will emulate VSCode. So I need a lightweight TabCtrl(PageCtrl) similar to VSCode, and I don't know if your new TabControl can emulate VSCode's TabCtrl(PageCtrl).
> 
> Also, SSTabEx is too heavy and complex to be considered by me.
> 
> *Edit:*
> VSCode's TabCtrl(PageCtrl) provides "window splitting" feature, just like a Container-Splitter.



Maybe this will do, since you use RC6. Just change the drawing styles if you prefer a different look.

https://www.vbforums.com/showthread....(Firefox-like)

----------


## Black_Storm

thanks for shares and i sent some issue in githube ,i sent some videos or screen shot animated about it,i dont know its about my windows tested in (new installed xp and vb only) and win 8 64 bit too or etc

----------


## SearchingDataOnly

> Maybe this will do, since you use RC6. Just change the drawing styles if you prefer a different look.
> 
> https://www.vbforums.com/showthread....(Firefox-like)


I studied your controls carefully and it's fantastic. Thank you very much.

Also, I've been trying to find an example of developing CodeEditor in RC6. You're a master of controls, and it would be great if you could provide some help.

----------


## bgerasimoski

Excellent control, thanks for sharing  :Smilie:

----------


## Eduardo-

Thanks for all the comments  :wave: .

Updated:

2022-11-15 OLE OCX version changed to 2 because binary compatibility was broken.
2022-11-15 Added two new default themes.
2022-11-15 Changed HighlightMode and HighlightModeTabSel properties type from an Enum to a Long using flags. Added the FlatDrawBorder flag, and two related color properties: FlatTabBorderColorHighlight and FlatTabBorderColorTabSel.
2022-11-14 Improvements in tab dragging (changing tab position when CanReorderTabs = True).
2022-11-12 Added middle click handling to tabs in TDIMode.

----------


## softv

Just today, just a while ago only, I noticed this new control. Great! Wow! Thanks a many.

One quick question: 
Actually, I wanted this in SSTabEx itself. i.e. is it possible to have Unicode tooltips for the Tab (as a whole) as well as for the individual Tabs? If that feature is already available, then kindly let me know how to set texts in Unicode as tooltips for the Tabs (and the Tab, as a whole, as well)?

Thanks once again, for all your wonderful controls.

Kind Regards.

----------


## Eduardo-

Hello softv. No, the tooltips are not Unicode currently but I'll keep in mind the request.

----------


## Eduardo-

I added Unicode support for the TabToolTipText property (*).
On the other hand, the ToolTipText property is handled by VB and does not support Unicode (anyway I don't imagine a situation where someone could need a tool tip for the whole control).
Please test.

(*) You can set the TabToolTipText for each tab at design time from the 'Tabs' property page.

----------


## softv

So quickly!!! You are one great soul, Eduardo. *Thanks a TON*. I did download and test the latest version. I was able to set and see Unicode text, *not only in the ToolTips but in Captions too*!!! Wow! Actually, Unicode in Tab Captions would have been my next request. But, I am able to see it now itself. Fantastic. Great many great many thanks.


But, one thing. I was able to achieve the above via code only. Though that itself is *quite immense* and totally enough for me, since you have written that its possible to set the Unicode text at design time itself!!!, I wish to give the following feedback (for setting the ToolTipText in Unicode via 'Properties' page alone and not via code):
--
The Unicode characters (for a tab's tooltip) change to questions marks, as soon as the 'Properties' window is closed. So, the tab's tooltip's text also appears as question marks only, during runtime. May be I am doing some mistake because I just gave it a quick-test only, because of lack of time (as of now). 


In case if its a mistake from my side only, then kindly please let me what mistake I am doing. In case its not a mistake from my side, then, I am sure you will release the next version where things are set right. So, in either case, thanks a TON for the Unicode support in ToolTipText at Design time itself!!!!! Unicode support for ToolTip texts (as well as Captions, if possible - since it is possible via code now) at design time would be a huge time-saver and an absolute treat for me. 


Anyway, as already mentioned by me, "Tab ToolTip and Caption texts via code" - that itself is Immense. Thanks a TON, once again.
--


Yes, Unicode support for the whole control's ToolTip text is not much of a need.


Kind Regards.

----------


## Eduardo-

> So quickly!!! You are one great soul, Eduardo. *Thanks a TON*. I did download and test the latest version. I was able to set and see Unicode text, *not only in the ToolTips but in Captions too*!!! Wow! Actually, Unicode in Tab Captions would have been my next request. But, I am able to see it now itself. Fantastic. Great many great many thanks.


The Unicode captions were available from the first version of SSTabEx... I mean, the tab captions have been always Unicode capable through code.

Not the Tab tooltips, because they used the standard VB extender tooltip mechanism that is ANSI based.
(But now I changed them to use API, and they are Uniocode capable now).




> But, one thing. I was able to achieve the above via code only. Though that itself is *quite immense* and totally enough for me, since you have written that its possible to set the Unicode text at design time itself!!!, I wish to give the following feedback (for setting the ToolTipText in Unicode via 'Properties' page alone and not via code):
> --
> The Unicode characters (for a tab's tooltip) change to questions marks, as soon as the 'Properties' window is closed. So, the tab's tooltip's text also appears as question marks only, during runtime. May be I am doing some mistake because I just gave it a quick-test only, because of lack of time (as of now). 
> 
> 
> In case if its a mistake from my side only, then kindly please let me what mistake I am doing. In case its not a mistake from my side, then, I am sure you will release the next version where things are set right. So, in either case, thanks a TON for the Unicode support in ToolTipText at Design time itself!!!!! Unicode support for ToolTip texts (as well as Captions, if possible - since it is possible via code now) at design time would be a huge time-saver and an absolute treat for me. 
> 
> 
> Anyway, as already mentioned by me, "Tab ToolTip and Caption texts via code" - that itself is Immense. Thanks a TON, once again.
> ...


Yes, you are right, the captions and tooltips set from the property page are not Unicode capable. The reason: I use normal VB textboxes there, and the VB textboxes are not Unicode capable.
To make it possible to enter Unicode at design time, I should incorporate a Unicode capable textbox into the project. In that case I think I should try to find some simple usercontrol that allows basic Unicode text entering, because a full featured Unicode textbox would mean to add several files. Not sure whether it worth...

----------


## softv

// To make it possible to enter Unicode at design time, I should incorporate a Unicode capable textbox into the project. In that case I think I should try to find some simple usercontrol that allows basic Unicode text entering, because a full featured Unicode textbox would mean to add several files. //

Please see this - https://www.vbforums.com/showthread....-Shape-Control - posted by LaVolpe more than a decade back

If you have already seen the above control and thus you are very well aware about the* technique used by LaVolpe* in his above project* to hold Unicode text in text boxes during design time itself* but you feel it is not feasible to adopt that technique in Newtab, then no need to read the following. Otherwise, kindly please do read ahead.

LaVolpe's control is a 'Shape' control actually. But, the control takes 'Text' also as one of its forms (apart from rectangle, ellipse, polygon, etc.)

The 'Text' property is accessible via the 'Properties' page. As in the case of NewTab control, one can right click on this control also & select "Properties" for a new 'Properties' screen to get displayed. Therein, one can choose 'Text' (from a listbox) for the 'Shape' field and *in the 'Text' field, one can key in Unicode text*.

LaVolpe has mentioned in one of his messages (in his abovementioned post) as follows:
--
ShapeText. *To enable unicode during design time, use the property page*. ShapeText property accepts unicode during runtime also.
--

On my testing, the entered Unicode text is maintained at all times in LaVolpe's Shape control, once it has been input in the 'Text' field. 

I find a "cUniTextBox.cls" class in LaVolpe's project wherein he has mentioned in that class' documentation (at the very start itself)
--
' *A simple callback class used to offer unicode textbox on the property page*
' It is truly simple and only has a couple properties/methods, but works well
' Should you want to use this for your own projects, here is how you can set it up
... .. .
...
..
.
--

I have just shared above what I found. That's all. LaVolpe's project has only one text box but NewTab has 'as many textboxes' as there are tabs. So, the technique used by LaVolpe may be too much of a work for NewTab, to safely hold the Unicode texts, persistently, at both Design and Runtime. But then, I am not an expert like you. So, *as an expert, if you feel, it would not be too much of a work to adopt LaVolpe's technique in NewTab*, then you may kindly proceed ahead to adop it. It would be a treat to see Unicode text entered for tabs' ToolTips at Design time itself.

All said and done, as already mentioned by me in my earlier message, "Tab ToolTip and Caption texts via code" - that itself is Immense. *Thanks a TON, once again*.

Kind Regards.

----------


## Eduardo-

Thanks, something like that I was talking about when I said "something simple".




> NewTab has 'as many textboxes' as there are tabs.


No, it has only one TextBox per property, the data for each tab is stored in an array variable (Private mTabData() As T_TabDataP).

OK, I'll see to implement that (at some point).
Thank you.

----------


## Eduardo-

Done, please test.
One thing that I noticed and didn't like is that the arrows keys don't work (to change the insertion position).

----------


## softv

> Done, please test.
> One thing that I noticed and didn't like is that the arrows keys don't work (to change the insertion position).


Yes, its working great and really nice to see Caption and Tooltip accepting Unicode text at design time itself.

But, as you say, the arrow keys do not work as intended. They are shifting focus to the previous or next fields. I needed to press the arrow keys twice, initially, to notice this behaviour. This behaviour could be definitely irksome for most (if not all), I feel, personally. So, if this issue can be set right only, it would be ideal for most, I feel, personally. And, of course, it would feel great too, for me, as I requested this feature very much. But, in case this issue cannot be set right, I don't know what you would plan to do. As for me, I can live with this issue, since I would always love to see Unicode in Caption and Tooltips at design time. Anyway, as written earlier, "Unicode texts for Tab ToolTip and Caption via code" - that itself was immense. Thanks a TON, once again.

Kind Regards.

----------


## Eduardo-

If you want, you can share "themes" with other users by posting them here.

You can do it from the "Themes" property page and the "Copy this theme" button:



Then post it here.
(Everybody is invited.)

----------


## Elroy

It's a bit hard to see, but I'm getting error 91 when exiting my project (in the IDE) that has your tab control.

I've attached the offending project.  Be sure to open with the PersistentDebugPrint.VB*G* file.

All I did to your NewTabCtl was to pull all the source files into one folder, remove any compatibility requirements, edit the NewTabCtl.vbp to remove the path specifications, and then include the project within the PersistentDebugPrint.VBG file.  I also played around with a few of your properties from your properties window, but that's it.

To get it going, I just expanded the scope of your OERN that you already had.  My changes to get it going:



```

    On Error Resume Next

    For c = 1 To mSubclassedControlsForPaintingHwnds.Count
        iHwnd = mSubclassedControlsForPaintingHwnds(c)
        DetachMessage Me, iHwnd, WM_PAINT
        DetachMessage Me, iHwnd, WM_MOVE
    Next c
    Set mSubclassedControlsForPaintingHwnds = Nothing

    For c = 1 To mSubclassedFramesHwnds.Count
        iHwnd = mSubclassedFramesHwnds(c)
        DetachMessage Me, iHwnd, WM_PRINTCLIENT
        DetachMessage Me, iHwnd, WM_MOUSELEAVE
    Next c
    Set mSubclassedFramesHwnds = Nothing

    For c = 1 To mSubclassedControlsForMoveHwnds.Count
        iHwnd = mSubclassedControlsForMoveHwnds(c)
        DetachMessage Me, iHwnd, WM_WINDOWPOSCHANGING
    Next c

    Set mSubclassedControlsForMoveHwnds = Nothing
    mTabIconFontsEventsHandler.Release
    Set mTabIconFontsEventsHandler = Nothing

    If mHandIconHandle <> 0 Then
        DestroyCursor mHandIconHandle
        mHandIconHandle = 0
    End If

    On Error GoTo 0


```

All in the DoTerminate procedure within the ctlNewTabCtl.ctl file.  Attached doesn't have this fix.  It's your original code.

----------


## Elroy

Hmmm, I'm also trying to use your TDIMode feature.

However, when you X (close) a tab, it appears to just hide it rather than truly close it, and it also leaves that tab's index active.  Done that way, it sure makes it tough to keep track of things.

I was hoping to just number my tabs 1, 2, 3, etc, and be able to reference those tabs with those numbers.  If one were deleted, I'd just re-number all the subsequent captions.  But, I can't do that with the way it works (without making some kind of complex cross-reference index).

Maybe I should just do my own version of TDI with your control.  I'd also like the ability to prohibit closing certain tabs (and haven't yet looked to see if that's a tab property).

EDIT:  I found your TDIGetTabNumberByTabIndex and TDIGetTabIndexByTabNumber properties.  That's probably what I need.  I'll see if I can figure how what they're telling me.

----------


## Eduardo-

> It's a bit hard to see, but I'm getting error 91 when exiting my project (in the IDE) that has your tab control.
> 
> I've attached the offending project.  Be sure to open with the PersistentDebugPrint.VB*G* file.


The issue is that you are reloading the form from its Form_Terminate event, that's of course something that shouldn't be happening.

It happens here:



```
Private Sub Form_Terminate()
    '
    ' Remove our subclassing so we can safely remove its related thunk.
    RemoveWindowSubclass Me.hWnd, pMessageThunkPointer, Me.hWnd
```

If you access any property after a form was unloaded, you load it again.

The Form_Load event does not fire, but the UserControl_Initialize's do.
Why? Because VB is ending the program, and doing so it enters in a unwanted state and it "tries to do its best" (that many times is not good).

The mSubclassedControlsForPaintingHwnds collection was instantiated in the UserControl_Initialize event but it was already set to Nothing by VB before it raises the UserControl_Terminate event. 
When shutting down, at the end VB sets to Nothing every object, but in an nondeterministic order.

OK; I added the protection to handle that situation (it is already on the Github repository).



```
Private Sub DoTerminate()
    Dim c As Long
    Dim iHwnd As Long
    
    If mUserControlTerminated Then Exit Sub
    mUserControlTerminated = True
    
    tmrShowTabTTT.Enabled = False
    Set mToolTipEx = Nothing
    If (mFormHwnd <> 0) And mAmbientUserMode Then
        On Error Resume Next
        DetachMessage Me, mFormHwnd, WM_SYSCOLORCHANGE
        DetachMessage Me, mFormHwnd, WM_THEMECHANGED
        DetachMessage Me, mFormHwnd, WM_NCACTIVATE
        DetachMessage Me, mFormHwnd, WM_GETDPISCALEDSIZE
        On Error GoTo 0
    End If
    If mSubclassed Then
        If mAmbientUserMode Then
            On Error Resume Next
            DetachMessage Me, mUserControlHwnd, WM_MOUSEACTIVATE
            DetachMessage Me, mUserControlHwnd, WM_SETFOCUS
            DetachMessage Me, mUserControlHwnd, WM_DRAW
            DetachMessage Me, mUserControlHwnd, WM_INIT
            DetachMessage Me, mUserControlHwnd, WM_SETCURSOR
            On Error GoTo 0
            mCanPostDrawMessage = False
        Else
            On Error Resume Next
            DetachMessage Me, mUserControlHwnd, WM_LBUTTONDOWN
            DetachMessage Me, mUserControlHwnd, WM_LBUTTONUP
            DetachMessage Me, mUserControlHwnd, WM_LBUTTONDBLCLK
            On Error GoTo 0
        End If
    End If
    mSubclassed = False
    
    tmrTabMouseLeave.Enabled = False
    tmrDraw.Enabled = False
    tmrCancelDoubleClick.Enabled = False
    tmrCheckContainedControlsAdditionDesignTime.Enabled = False
    tmrHighlightEffect.Enabled = False
    
    Set mParentControlsTabStop = Nothing
    Set mParentControlsUseMnemonic = Nothing
    Set mContainedControlsThatAreContainers = Nothing
    
    If Not mSubclassedControlsForPaintingHwnds Is Nothing Then
        For c = 1 To mSubclassedControlsForPaintingHwnds.Count
            iHwnd = mSubclassedControlsForPaintingHwnds(c)
            On Error Resume Next
            DetachMessage Me, iHwnd, WM_PAINT
            DetachMessage Me, iHwnd, WM_MOVE
            On Error GoTo 0
        Next c
        Set mSubclassedControlsForPaintingHwnds = Nothing
    End If
    
    If Not mSubclassedFramesHwnds Is Nothing Then
        For c = 1 To mSubclassedFramesHwnds.Count
            iHwnd = mSubclassedFramesHwnds(c)
            On Error Resume Next
            DetachMessage Me, iHwnd, WM_PRINTCLIENT
            DetachMessage Me, iHwnd, WM_MOUSELEAVE
            On Error GoTo 0
        Next c
        Set mSubclassedFramesHwnds = Nothing
    End If
    
    If Not mSubclassedControlsForMoveHwnds Is Nothing Then
        For c = 1 To mSubclassedControlsForMoveHwnds.Count
            iHwnd = mSubclassedControlsForMoveHwnds(c)
            On Error Resume Next
            DetachMessage Me, iHwnd, WM_WINDOWPOSCHANGING
            On Error GoTo 0
        Next c
        Set mSubclassedControlsForMoveHwnds = Nothing
    End If
    If Not mTabIconFontsEventsHandler Is Nothing Then
        mTabIconFontsEventsHandler.Release
        Set mTabIconFontsEventsHandler = Nothing
    End If
    If mHandIconHandle <> 0 Then
        DestroyCursor mHandIconHandle
        mHandIconHandle = 0
    End If
End Sub
```

----------


## Eduardo-

In the Form_Initialize event, store the form hWnd into a variable, and use that at the form Terminate, not the form's property.



```
Private mFormhWnd As Long

Private Sub Form_Initialize()
    mFormhWnd = Me.hWnd
End Sub

Private Sub Form_Terminate()
    '
    ' Remove our subclassing so we can safely remove its related thunk.
    RemoveWindowSubclass mFormhWnd, pMessageThunkPointer, mFormhWnd
```

----------


## Elroy

Thanks Eduardo.  And yeah, that Me.hWnd in the Terminate event was an oversight on my part.

Thanks for looking at it, and I'll store the hWnd as you suggest.

Again, this is FANTASTIC work on your part.   :Smilie:

----------

