Color Coded Tabs

Here you can propose new features, make suggestions etc.

Moderators: Hacker, petermad, Stefan2, white

User avatar
Vochomurka
Power Member
Power Member
Posts: 816
Joined: 2005-09-14, 22:19 UTC
Location: Russia
Contact:

Post by *Vochomurka »

TWinKey can not only colorize tabs, but assign an icon to each. And there is also another solution
Single user license #329241
PowerPro scripts for Total Commander
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50386
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

???
There is no Windows function to do this! Do I need to disable themes?
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Highlighting is done via tab control message, and it only allows one color. However I think tabs may be colored using custom erasing of background (i.e. we should be able to use any desired background color for tab header rectangles when Windows needs to redraw the control).
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50386
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Highlighting is done via tab control message
Hmm, do you happen to know the message? Couldn't find anything.
However I think tabs may be colored using custom erasing of background (i.e. we should be able to use any desired background color for tab header rectangles when Windows needs to redraw the control).
There is no owner drawing of tab headers. I would have to create my own tab control with owner drawing everything calling the theme commands myself.
Author of Total Commander
https://www.ghisler.com
User avatar
Lefteous
Power Member
Power Member
Posts: 9536
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2ghisler(Author)
There is no owner drawing of tab headers.
Actually there is but it doesn't cover the whole tab header area just the content area of the header. Just try and judge if this is enough for you. For me it seems TWinKey also uses only the content area for drawing.

In order to draw the tab headers do the following:
Create the tab using the TCS_OWNERDRAWFIXED style. Then draw in the normal WM_DRAWITEM handler in the parent window.
https://msdn.microsoft.com/en-us/library/windows/desktop/bb760549%28v=vs.85%29.aspx
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

ghisler(Author) wrote:Hmm, do you happen to know the message? Couldn't find anything.
I got it from mentioned PowerPro script, the message is TCM_HIGHLIGHTITEM (but it doesn't allow specifying highlight color, it depends on Windows theme).
ghisler(Author) wrote:There is no owner drawing of tab headers. I would have to create my own tab control with owner drawing everything calling the theme commands myself.
But I still think that background erasing for entire tab control is still done using WM_ERASEBKGND, so overriding it should allow coloring tab headers as we like: you fill tab entire control with default background color but tab headers with another ones (there is a message TCM_GETITEMRECT that returns rectangles for tab headers).
Lefteous wrote:Create the tab using the TCS_OWNERDRAWFIXED style. Then draw in the normal WM_DRAWITEM handler in the parent window.
It may reguire drawing entire tabs by hands.
User avatar
Lefteous
Power Member
Power Member
Posts: 9536
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2MVV
It may reguire drawing entire tabs by hands.
Yes you have to draw the entire tab header client area. Or did you mean something else? I have tried it and that's the way it works. Do you think it's too difficult to draw a filled rectangle and a text in this area?

As discussed long ago there is also quite different approach to this feature. Using colored icons in tab headers. This would also work fine and doesn't even require custom drawing, a dirty hack or a custom control. It even works for all kind of visual styles.
Last edited by Lefteous on 2015-04-27, 13:02 UTC, edited 2 times in total.
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Lefteous wrote:Yes you have to draw the entire tab header client area. Or did you mean something else? I have tried it and that's the way it works. Do you think it's too difficult to draw a filled rectangle and a text in this area?
I pretty think it is difficult to draw 3D-looked tab header borders to make them look just like in Windows theme.
Lefteous wrote:Here is a picture for illustration. On top you see TWinKey in action and below you see the tab client area in red.
Where can I see this picture?
User avatar
Lefteous
Power Member
Power Member
Posts: 9536
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2MVV
I pretty think it is difficult to draw 3D-looked tab header borders to make them look just like in Windows theme.
It's really just the client area - no necessity to draw the border.
Where can I see this picture?
Sorry here it is. I have added a third image section which illustrates how icons instead of owner drawn client area could look like, so:

1. TWinkey
2. Client area in tab header which can be drawn when using custom drawing in tab control (red rectangle)
3. Icon in tab header (basic feature of Windows tab control, no custom drawing required)

[img]http://fs2.directupload.net/images/150427/dxgpz2n8.png[/img]
User avatar
Hacker
Moderator
Moderator
Posts: 13141
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Lefteous wrote:1. TWinkey
2. Client area in tab header which can be drawn when using custom drawing in tab control (red rectangle)
3. Icon in tab header (basic feature of Windows tab control, no custom drawing required)

[img]http://fs2.directupload.net/images/150427/dxgpz2n8.png[/img]
While I personally do not use TWinKey, I have to admit, the gradient coloring is beautiful.
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

2. Client area in tab header which can be drawn when using custom drawing in tab control (red rectangle)
Looks good.

It seems that even with overriden WM_ERASEBKGND tabs are still repainted after erasing background.
User avatar
Lefteous
Power Member
Power Member
Posts: 9536
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

I have to admit, the gradient coloring is beautiful.
:roll:

In my opinion having just the client area for drawing is quite a restriction. I may not be to easy to find something that works theme-independent and also with the tab header label. A black font means you can just light colors.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50386
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Thanks for the owner draw info! But I guess I should use ownerdrawvariable to adjust to the dir name length?
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Where have you found ownerdrawvariable? I can't get anything on MSDN.
User avatar
Lefteous
Power Member
Power Member
Posts: 9536
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2ghisler(Author)
I guess I should use ownerdrawvariable to adjust to the dir name length?
The tab header width is defined by the elements in the TCITEM structure in the TCM_INSERTITEM message. So you add the tab header including label (or even an icon) as usual and then start drawing in WM_DRAWITEM. You can of course do some tricking in TCM_INSERTITEM by using a very long string to get some space.

So there is no WM_MEASUREITEM (and no variable owner-draw) send for tab headers and it's not really necessary.
Post Reply