首先,要利用函数 DZGetDesktopIconWindow 找到包含桌面图标的窗口。
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;
下面就是获得透明效果的主体代码
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;