Caption for TTabControl
Asked Answered
O

3

6

I'm looking for a way of implementing a sort of inset caption before a set of tabs, something like this:

enter image description here

The tab set is not supposed to be multi-line, will only be horizontal and laid out at the top. However it should be correctly scrollable when there are too many tabs.

I fear I'm going to be restricted here with regard to using third-party controls, but I could use subclassing on the standard TTabControl to add the necessary changes to the standard looks and behaviour. (I don't need it to be TPageControl, because it's only the specific arrangement of the tabs that I am interested in.)

Maybe there's some way of implementing this with craftily arranged combination of standard controls, which, despite my endevours, has escaped me.

Basically, any ideas or pointers are welcome.

Oh, and additional requirement is, it should blend well with desktop themes.

Overcrop answered 7/4, 2011 at 12:30 Comment(0)
A
1

Granted some time has passed, but I recently needed this style and found you can do it with the TMS Software TAdvOfficePager. It has a property FixedTabs, which I set to 1 in this case. It also has an OnChanging event where you can prevent access to a tab, in this case I used AllowChange := (ToPage > 0); Lastly, I set the first tab to disabled.

Then just style the first tab different than the rest and you can have something like this:

enter image description here

Amblyopia answered 15/1, 2018 at 22:42 Comment(1)
This seems to be ticking all the boxes. Except it's a third-party component, and a paid one too. Which is perfectly fair as far as I'm concerned, because, given the number of features listed at the component's page, they must have put a lot of effort. It's just that I doubt my company will agree to pay so much. Anyway, thanks for finding and sharing this.Overcrop
I
0

Have you tried to make the first tab to be the caption you want. With some additional logic you can restrict the selection of this tab.

I don't know if you can control the style of each tab individually to make the first one look as it is not the tab.

Insecurity answered 7/4, 2011 at 12:33 Comment(1)
Thanks, I was thinking about that, actually. Sustaining a specific look and behaviour for a certain tab could be somewhat problematic indeed. But a much bigger problem would be to implement it together with the correct scrolling of tabs.Overcrop
G
0

Here is crafty arrangement of controls that will work. I have done this sort of thing in the past. Best of all it automatically handles scrolling of tabs.

Crafty arrangement

Goldfarb answered 17/10, 2014 at 2:45 Comment(3)
Not downvoting your answer, but have you tested this to make sure it will "blend well with desktop themes"? It would have been better to annotate a copy of the runtime image of the form, rather than design-time that doesn't demonstrate the actual appearance or how it "blends" with runtime themes.Illassorted
@Ken-White, Mea culpa. This was knocked up in Delphi 5 (no themes). I should have done a run-time screengrab. That said, this uses standard VCL stuff which, as I've said, have used this sort of arrangement in the past without issues. I suppose I was focusing on the problem of tab scrolling for this answer.Goldfarb
Thank you for the suggestion. I considered a similar approach, only with a panel instead of a page control (I didn't need multiple pages, only tabs). The issue was same as with your arrangement: the upper border of the panel was always visible, which was unacceptable because I really wanted the seamless looks of a TTabControl with a caption before the tabs.Overcrop

© 2022 - 2025 — McMap. All rights reserved.