Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Shaded column colour in XP Explorer

56 views
Skip to first unread message

Jeremy Collins

unread,
Apr 27, 2005, 11:14:12 AM4/27/05
to
Hi all,

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

eshipman

unread,
Apr 27, 2005, 12:19:59 PM4/27/05
to
In article <op.spwcly0y4al0tm@office>, jd.co...@ntlworld-not.com says...


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;

Mark Williams

unread,
Apr 27, 2005, 1:07:17 PM4/27/05
to

> 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

unread,
Apr 27, 2005, 1:17:35 PM4/27/05
to
In article <426f...@newsgroups.borland.com>, mark@{removethis}skwirel.com says...
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.

Mark Williams

unread,
Apr 27, 2005, 2:16:54 PM4/27/05
to
Had a look at customizing appearance. It doesn't give you an option to
change the explorer windows selected column color.

"eshipman" <mr_delphi_developer@yahoo!!!.com> wrote in message
news:MPG.1cd9852be...@forums.borland.com...

eshipman

unread,
Apr 27, 2005, 3:48:22 PM4/27/05
to
In article <426fd714$1...@newsgroups.borland.com>, mark@{removethis}skwirel.com says...

> Had a look at customizing appearance. It doesn't give you an option to
> change the explorer windows selected column color.

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,

Jeremy Collins

unread,
Apr 28, 2005, 4:53:17 AM4/28/05
to
On Wed, 27 Apr 2005 19:16:54 +0100, Mark Williams
<mark@{removethis}skwirel.com> wrote:

> 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

Jeremy Collins

unread,
Apr 28, 2005, 4:56:17 AM4/28/05
to
On Wed, 27 Apr 2005 17:19:59 +0100, eshipman
<mr_delphi_developer@yahoo!!!.com> wrote:


> 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

Dave C

unread,
May 9, 2005, 11:57:37 AM5/9/05
to
You don't have to paint this yourself. Windows XP has implemented a new
windows message you need to send to the listview. Take a look on MSDN
to see the pages for the LVM_SETSELECTEDCOLUMN and LVM_GETSELECTEDCOLUMN
messages. The LVM_SETSELECTEDCOLUMN message will highlight the
specified column for you. It only works on windows xp, and you must be
using ComCtl version 6 (using themes)
0 new messages