Mega Code Archive

 
Categories / Delphi / Graphic
 

How to make desktop icon titles transparent

Title: How to make desktop icon titles transparent Question: Windows' Desktop Properties dialog does not seem to include an option for making icon titles transparent. Here's how to do it in your code. Answer: First, let's find the window which contains the desktop icons. This is the function to do it: uses Windows; function DZGetDesktopIconWindow: HWND; begin Result := FindWindow(PChar('Progman'), PChar('Program Manager')); Result := FindWindowEx(Result, 0, PChar('SHELLDLL_DefView'), nil); Result := FindWindowEx(Result, 0, PChar('SysListView32'), nil); end; And this is how to achieve the transparency effect: uses Windows, CommCtrl; procedure DZSetDesktopIconTransparent; var Desktop : HWND; begin Desktop := DZGetDesktopIconWindow; ListView_SetTextBkColor(Desktop, MAXDWORD); ListView_RedrawItems(Desktop, 0, Pred(ListView_GetItemCount(Desktop))); UpdateWindow(Desktop); end; By the way, you may also want to set any icon title text/background color, not only transparent. This is how to do it: uses Windows, CommCtrl, Graphics; // for the definition of TColor only procedure DZSetDesktopIconColors(const FColor, BColor: TColor); var Desktop : HWND; begin Desktop := DZGetDesktopIconWindow; ListView_SetTextColor(Desktop, FColor); ListView_SetTextBkColor(Desktop, BColor); ListView_RedrawItems(Desktop, 0, Pred(ListView_GetItemCount(Desktop))); UpdateWindow(Desktop); end; In the procedure above FColor is the Foreground (Text) color, BColor is the Background color. And finally, this will reset the colors back after you've messed with them :) uses Windows; procedure DZResetDesktopIconColors; var Kind, Color : Integer; begin Kind := COLOR_DESKTOP; Color := GetSysColor(COLOR_DESKTOP); SetSysColors(1, Kind, Color); end; In addition I may suggest finding out for yourself other functions declared in CommCtrl for the ListView controls (the desktop window with icons is one such control, the Explorer window with the icons is another). There are many possibilities there.