Page 4 of 5

Posted: 2015-04-24, 15:31 UTC
by Vochomurka
TWinKey can not only colorize tabs, but assign an icon to each. And there is also another solution

Posted: 2015-04-27, 08:31 UTC
by ghisler(Author)
???
There is no Windows function to do this! Do I need to disable themes?

Posted: 2015-04-27, 08:35 UTC
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).

Posted: 2015-04-27, 08:45 UTC
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.

Posted: 2015-04-27, 09:19 UTC
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

Posted: 2015-04-27, 11:26 UTC
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.

Posted: 2015-04-27, 11:55 UTC
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.

Posted: 2015-04-27, 12:15 UTC
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?

Posted: 2015-04-27, 13:01 UTC
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]

Posted: 2015-04-27, 18:32 UTC
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.

Posted: 2015-04-28, 12:28 UTC
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.

Posted: 2015-04-28, 13:29 UTC
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.

Posted: 2015-04-28, 17:11 UTC
by ghisler(Author)
Thanks for the owner draw info! But I guess I should use ownerdrawvariable to adjust to the dir name length?

Posted: 2015-04-28, 18:10 UTC
by MVV
Where have you found ownerdrawvariable? I can't get anything on MSDN.

Posted: 2015-04-28, 20:31 UTC
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.