Neil J. Rubenking <jrubenki@SPAM-B-GONE@mother.com>
program Test;
{$APPTYPE CONSOLE}
USES Windows, Messages, commctrl;
function GetLVHan : HWnd;
// Get the handle of the desktop listview
begin
Result := FindWindowEx(FindWindowEx(FindWindowEx(
GetDesktopWindow, 0, 'Progman', nil), 0,
'SHELLDLL_DefView', nil), 0, 'SysListView32', nil);
end;
function ActiveDesktop : Boolean;
begin
Result := FindWindowEx(FindWindowEx(FindWindowEx(
GetDesktopWindow, 0, 'Progman', nil), 0,
'SHELLDLL_DefView', nil), 0, 'Internet Explorer_Server',
nil) <> 0;
end;
procedure SetListviewStyleSmall(H : HWnd);
VAR S : StyleStruct;
begin
S.StyleOld := GetWindowLong(H, GWL_STYLE);
S.StyleNew := S.StyleOld AND NOT LVS_TYPEMASK;
S.StyleNew := S.StyleNew OR LVS_ICON;
SetWindowLong(H, GWL_STYLE, S.StyleNew);
SendMessage(H, WM_STYLECHANGED, GWL_STYLE, Integer(@S));
ShowWindow(H, SW_SHOWNORMAL);
end;
begin
IF ActiveDesktop THEN
begin
WriteLn('Turn off Active Desktop first.');
Halt;
end;
SetListViewStyleSmall(GetLVHan);
WriteLn('The desktop listview should now have small icons');
WriteLn('Switch to Active Desktop and watch them disappear');
WriteLn('(to get them back, log off and on again)');
WriteLn;
WriteLn('WHY does this happen? How can it be prevented?');
end.