4

http://screenshots.en.sftcdn.net/en/scrn/39000/39972/xentient-labels-1.jpg

Is is possible to change background color of the items in Windows Explorer like the Xentient Labels application does ? Is it possible to do so from Delphi XE2 in Windows 7 ?

7
  • 1
    If I were King, all file listings would always be in black and white, monospaced text. But that's just me, I guess ;)
    – paulsm4
    May 21, 2012 at 7:19
  • As Hans Passant said here it won't work in Windows 7. You would find the handle to the Windows Explorer's list view and use as the easiest way the ListView_SetTextBkColor macro.
    – TLama
    May 21, 2012 at 7:20
  • 4
    It would be great if you could add some blinking text in there too May 21, 2012 at 7:21
  • 2
    @David, yeah blinking text and jumping items :-) I'll try it...
    – TLama
    May 21, 2012 at 7:24
  • 1
    ListView in Windows 7 has the DirectUIHWND class name and doesn't listen to the list view messages, so it's not possible in Windows 7.
    – TLama
    May 21, 2012 at 7:37

2 Answers 2

11

It's not possible to do this in Windows 7 since the Windows Explorer's list view uses the DirectUIHWND not SysListView32 as it was in Windows XP. The DirectUIHWND class control doesn't listen the list view messages, so you cannot use the ListView_SetTextBkColor macro to change text back color as you could on Windows XP.

With the following simple test you can verify it. Let's have an edit box and button on the form. In that edit box enter the handle to the Windows Explorer's list view control (obtained e.g. by Spy++) and in button's press run the following code:

uses
  Winapi.CommCtrl;

procedure TForm1.Button1Click(Sender: TObject);
var
  ListViewHandle: HWND;
begin
  ListViewHandle := StrToInt(Edit1.Text);
  ListView_SetTextBkColor(ListViewHandle, $0000CCFF);
end;

This Spy++ screenshot from Windows 7 shows the class name of the Explorer's list view (in Windows XP it was SysListView32 controllable by standard list view messages, the DirectUIHWND doesn't react to them).

enter image description here

1
  • Now looking at the picture from question, the ListView_SetTextBkColor macro wouldn't be the right one. It changes the color background for all items in a list view. However it still doesn't change the fact the list view in Windows 7 Explorer doesn't listen the list view messages, so there's no need to search for the right one in this case.
    – TLama
    May 21, 2012 at 8:43
2

You can't color text, but you can add overlays like TortoiseSVN/CVS/Git/Groove/Dropbox/etc. does.

Screenshot of Explorer with overlay icons

(from https://tortoisesvn.net/screenshots.html)

2
  • 2
    link: Access forbidden, reload plz to other any image host
    – Gu.
    May 21, 2012 at 7:58
  • 1
    If the link is forbidden, just click enter on the address bar for the site with the forbidden error and it will now load. Forbidden links usually check the location you were sent from, by pressing enter on the address bar again you trick the site into thinking you are accessing the link directly from the site :)
    – user1175743
    May 21, 2012 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.