Page 1 of 1

Improve support for themes in XP, Vista and 7

Posted: 2009-01-14, 10:05 UTC
by Erik-DJ
Some VCL-components of TC look a little old (native Windows 2000 look) if TC is installed on Windows with themes enabled (Windows XP, Vista and 7). For example the headers in the two file-panes (Name, Ext, Size, Date, Attr) look old. You probably have the Delphi-sources of these components. Perhaps you could implement themes support for these components by using the standard ‘Themes.pas’ of Delphi (also available as open source for Delphi and Lazarus). Simple example for a TGrid:

Code: Select all

uses
  Themes;

procedure TGrid.DrawCell(ACol, ARow: Integer; ARect: TRect; AState: TGridDrawState);
var
  Details: TThemedElementDetails;
begin
  if (ThemeServices.ThemesEnabled) then
    begin
    Details := ThemeServices.GetElementDetails(thHeaderItemNormal);
    ThemeServices.DrawElement(Canvas.Handle, Details, ARect);
    Canvas.Brush.Style := bsClear;
    Canvas.Font.Assign(TitleFont);
    ...
    Canvas.TextOut(ARect.Left+2, CentreV(ARect, Canvas.TextHeight(lStr)), lStr);
    ...
    end;
  ...
  inherited;
end;
Search on the internet for “TThemeDBGrid” for a good example (http://jedqc.blogspot.com/search?q=TThemeDBGrid). For the “current directory bar” there is also a modern themed element.

Thanks. I like TC to look modern.

Posted: 2009-01-14, 11:36 UTC
by Lefteous
For the “current directory bar” there is also a modern themed element.
Can you provide more details?

Posted: 2009-01-17, 16:53 UTC
by Erik-DJ
For the 'current directory bar' you can use twMaxCaptionActive.

Link to this subject in anonther forum (poll):

http://ghisler.ch/board/viewtopic.php?t=15107

Posted: 2009-01-17, 18:20 UTC
by Erik-DJ
I did some Paint-Shop-Pro-ing and created an example of how TC could look with the use of standard Windows themes possibilities (Delphi ThemeServices). The left panel has the current look, the right one has the themed look:

http://home.kpn.nl/jong7810/z_netlinkedfiles/TC_example1.jpg

Changed:
- Current directory bar
- File panel headers
- Selected file under cursor
- ToolBar/ButtonBar

Posted: 2009-01-17, 19:17 UTC
by Herr Mann
The right looks better ...
I hope to TC 8, in 2 years. :cry:

Posted: 2009-01-18, 09:22 UTC
by petermad
2Erik-DJ

When sorting by multible columns (Shift+Click & Ctrl+Click) the sort order is indicated with small numbers - would that be supported by these themed file panel headers?

Posted: 2009-01-18, 09:47 UTC
by Lefteous
2Erik-DJ
Link to this subject in anonther forum (poll)
That's about the header control not about the current path element.
For the 'current directory bar' you can use twMaxCaptionActive.
Thtis won't help the author as he uses Delphi 2. You need to explain this on a Windows API level*.
ToolBar/ButtonBar
That's indeed interesting as this control seems to be themed alright in TC but it seems that ther are different toolbar stlyes on Vista. Could you provide details on this*?
Beside that I'm not sure if this stlye would look good when there is more than one line of buttonbar buttons.
Selected file under cursor
What you display here is not only a cursor but also a selection. As TC has its own way to cursor and selection many people (including me) won't be happy with the standard cursor which is just a dotted reactangle. It might be ok as standard but an additional custom solution is required.

*Parts and states documentation
http://msdn.microsoft.com/en-us/library/bb773210(VS.85).aspx


2petermad
When sorting by multible columns (Shift+Click & Ctrl+Click) the sort order is indicated with small numbers - would that be supported by these themed file panel headers?
So called owner-drawing must be used in any case. There two reasons for that:
1. Before Vista the standard header control doesn't have a sort order indicator. Even Explorer had to paint it like that.
2. The numbers as you mentioned.

In such a owner-drawing routine you can use the Windows theming functions togehther with the above mentioned parts&states to draw sich a header.

Posted: 2009-01-18, 10:16 UTC
by petermad
In such a owner-drawing routine you can use the Windows theming functions togehther with the above mentioned parts&states
Thanks for clarifying!