Vb, Delphi, .net, framework, C++, Java, Pascal,Visual Studio, Asm, Ruby, C#, j#, Cs, Html, Php, Perl, Asp, xHtml Get Free Souce Code Here...



Transparent Desktop Icon - Delphi

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.

0 comments:

Post a Comment