Mega Code Archive

 
Categories / Delphi / Graphic
 

Transparent Desktop Icon Text

Title: Transparent Desktop Icon Text Question: Ever annoyed at how the icons on your Desktop have those damned colored text backgrounds, wouldn't it be nice if your wallpaper showed through......heres how! Answer: Below is code to a quick unit I threw together to allow my Desktop icons to be transparent: unit Desktop; interface uses Windows, CommCtrl, Graphics; function FindDesktopWindow: HWND; function IsDesktopTransparent: Boolean; procedure SetDesktopIconColor(Foreground, Background: TColor; Trans: Boolean); procedure SetDefaultIconColors; implementation function FindDesktopWindow: HWND; var Window: HWND; begin Window := FindWindow('Progman','Program Manager'); Window := FindWindowEx(Window,0,'SHELLDLL_DefView',''); Window := FindWindowEx(Window,0,'SysListView32',''); Result := Window; end; function IsDesktopTransparent: Boolean; var BkColor: COLORREF; begin BkColor := ListView_GetTextBkColor(FindDesktopWindow); if BkColor $FFFFFFFF then Result := False else Result := True; end; procedure SetDesktopIconColor(Foreground, Background: TColor; Trans: Boolean); var Window: HWND; begin Window := FindDesktopWindow; if Trans = True then ListView_SetTextBkColor(Window,$FFFFFFFF) else ListView_SetTextBkColor(Window,Background); ListView_SetTextColor(Window, Foreground); ListView_RedrawItems(Window,0,ListView_GetItemCount(Window) - 1); UpdateWindow(Window); end; procedure SetDefaultIconColors; var Kind: Integer; Color: TColor; begin Kind := COLOR_DESKTOP; Color := GetSysColor(COLOR_DESKTOP); SetSysColors(0,Kind,Color); end; end.