I'm implementing sorting in a tree view.
Quick question - in Windows XP Explorer's detail view, the sorted
column is shaded. Is this a hard-coded colour (looks like $00F7F7F7
on my system), or should I be getting this colour from the shell
somewhere? (If so, where from).
Cheers,
--
jc
Here's some sample code I used to do what you are asking. I see
no color entries in the Windows color mapping for this shade
color. I translated this code from some C++ code I found that
did it.
procedure TForm1.ListView1CustomDrawSubItem(Sender: TCustomListView;
Item: TListItem; SubItem: Integer; State: TCustomDrawState;
var DefaultDraw: Boolean);
begin
if SubItem = iSelectedColumn then
Sender.Canvas.Brush.Color := RGB(247, 247, 247)
else
Sender.Canvas.Brush.Color := RGB(255, 255, 255);
end;
procedure TForm1.ListView1ColumnClick(Sender: TObject;
Column: TListColumn);
begin
TListView(Sender).Items.BeginUpdate;
// use a global to keep the value of the selected column
iSelectedColumn := Column.Index;
TListView(Sender).Items.EndUpdate;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
iSelectedColumn := 0;
end;
procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
if iSelectedColumn = 0 then
Sender.Canvas.Brush.Color := RGB(247, 247, 247)
else
Sender.Canvas.Brush.Color := RGB(255, 255, 255);
end;
By default treeview's color is clWindow, which is usually white. But
doesn't have to be. Likewise the selected color will not be hard coded in
this way. You should use one of the color constants, but I don't know what
one xp uses for the selected column.
"eshipman" <mr_delphi_developer@yahoo!!!.com> wrote in message
news:MPG.1cd9852be...@forums.borland.com...
Right, I couldn't find it either unless you use themes, which I don't.
>
> > > > procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;
> > > > Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
> > > > begin
> > > > if iSelectedColumn = 0 then
> > > > Sender.Canvas.Brush.Color := RGB(247, 247, 247)
> > > > else
> > > > Sender.Canvas.Brush.Color := RGB(255, 255, 255);
> > > > end;
> > > >
> > >
<SNIP>
> > > this way. You should use one of the color constants, but I don't know
> what
> > > one xp uses for the selected column.
> > >
> > Yes, I recall that I changed it for the unselected color to clWindow
> > but I could find no reference to the color used for the shaded column
> > other than the one in the code.
>
>
>
It is not one of the system defined color constants like COLOR_BTNHIGHLIGHT.
From some C# code:
private Color col_scolor = Color.WhiteSmoke; // Shade color
Found the declaration in GDIPlus.h:
WhiteSmoke = 0xFFF5F5F5,
> Had a look at customizing appearance. It doesn't give you an option to
> change the explorer windows selected column color.
That's right, it seems to be some sort of "contrasting colour" algorithm.
For example if you set the window colour to a light cream, then the
"shaded"
column colour becomes white.
--
jc
> Sender.Canvas.Brush.Color := RGB(247, 247, 247)
Heh, thanks. I think that comes out as $00F7F7F7, which is what I'm
using at the moment.
If you set Windows' window colour to this shade of grey, Explorer
then uses a darker shade for the selected column.
--
jc