Change the Text and Background Color of Desktop Icons

This sample shows how to change the color of the text as well as the background of your desktop icons. In the first icon the text is black with a transparent background. In the second icon I changed the text to red with a solid background.

Change the text color and text background color on your desktop icons
Download Source Code

Developed By

This sample was developed by EM. You can reach EM at


Typically we think of folders as a list of files and subdirectories. Thus, we look at them as standard system objects whose behavior has been coded once in some system library.

With Active Desktop, folders are more of a content provider. A folder is a system component holding content that, in its simplest form, provides a list of files and folders. Generally, a folder can contain anything, including records from a database, registry entries, e-mail messages, connected printers, scheduled tasks, etc.

Active Desktop is a layer of shell code sitting on top of the existing Windows shell. The Windows desktop is the root of the shell's object model. It is implemented as a special window that contains all the others created during the system's activity.

What the user perceives as the actual shell is a pile of windows. The first one in the z-order belongs to the Progman class. This window includes the actual shell view object. All these windows have the same dimensions as the screen.

The shell view object creates a window of class SHELLDLL_DefView. The view object is used to handle the folder's content, and presents it through a listview control. All the shortcuts on the desktop are rendered through a special, transparent listview with a style setting of LVS_ICON | LVS_SHAREIMAGELISTS | LVS_EDITLABELS | LVS_ALIGNLEFT | LVS_NOSCROLL.

The listview is a child of the SHELLDLL_DefView window and is of class SysListView32. Knowing this, we can change the characteristics of the listview, such as making an icon's background transparent, by getting its handle and sending the appropriate messages to it.

Once the listview's text background color is changed, we must force the listview to redraw itself. This is accomplished via a call to the InvalidateRect API passing it listview's handle. The second parameter of InvalidateRect specifies the coordinates of the rectangle to update. Passing zero selects the entire client area. InvalidateRect's final parameter is set True instructing it to erase the background of the update region.

A call to UpdateWindow sends a WM_PAINT message to the listview initiating the redraw.

The general steps involved are:

  • Get the handle of the Progman class window.
  • Get the handle of its SHELLDLL_DefView class child window.
  • Get the handle of its SysListView32 class child window - the listview.
  • Get the current text background color of the listview.
  • Set the current text background color of the listview.
  • Force the listview to redraw itself.

All the listview related messages are defined in the Commctrl.h header file which is included with VC++ or VB Enterprise edition. By examining the listview messages you will find that you can programmatically customize your desktop in a manner similar to that shown in this sample.


Using the Display applet in Control Panel, add a centered image to your desktop. Move an icon over the image. This will help make the icon's changes more noticeable. Run this program and click the button and watch the icon's text change. Experiment by uncommenting a different line in the ListView_SetTextBkColor function.

About TheScarms
About TheScarms

Sample code
version info

If you use this code, please mention ""

Email this page

© Copyright 2016 TheScarms
Goto top of page