Текущий архив: 2005.12.11;
Скачать: CL | DM;
ВнизПочему не работает практически идентичный код? Найти похожие ветки
← →
Igor_thief (2005-11-24 17:16) [0]Надо спрятать иконки на рабочем столе. При использовании кода приведенного ниже, ничего не получается, хотя подобный код (тоже приведен ниже), который должен менять вид меню Пуск работает нормально. В чем ошибка?
unit uIcons;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, shlobj;
Type
SHELLSTATE = record
Flags1: DWORD;
(*
BOOL fShowAllObjects:1;
BOOL fShowExtensions:1;
BOOL fNoConfirmRecycle:1;
BOOL fShowSysFiles:1;
BOOL fShowCompColor:1;
BOOL fDoubleClickInWebView:1;
BOOL fDesktopHTML:1;
BOOL fWin95Classic:1;
BOOL fDontPrettyPath:1;
BOOL fShowAttribCol:1;
BOOL fMapNetDrvBtn:1;
BOOL fShowInfoTip:1;
BOOL fHideIcons:1;
BOOL fWebView:1;
BOOL fFilter:1;
BOOL fShowSuperHidden:1;
BOOL fNoNetCrawling:1;
*)
dwWin95Unused: DWORD; // Win95 only - no longer supported pszHiddenFileExts
uWin95Unused: UINT; // Win95 only - no longer supported cbHiddenFileExts
// Note: Not a typo! This is a persisted structure so we cannot use LPARAM
lParamSort: Integer;
iSortDirection: Integer;
version: UINT;
// new for win2k. need notUsed var to calc the right size of ie4 struct
// FIELD_OFFSET does not work on bit fields
uNotUsed: UINT; // feel free to rename and use
Flags2: DWORD;
(*
BOOL fSepProcess: 1;
// new for Whistler.
BOOL fStartPanelOn: 1; //Indicates if the Whistler StartPanel mode is ON or OFF.
BOOL fShowStartPage: 1; //Indicates if the Whistler StartPage on desktop is ON or OFF.
UINT fSpareFlags : 13;
*)
end;
LPSHELLSTATE = ^SHELLSTATE;
TForm1 = class(TForm)
btnToggleIcons: TButton;
btnToggleXPStyle: TButton;
procedure btnToggleIconsClick(Sender: TObject);
procedure btnToggleXPStyleClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure ToggleTheIcons;
procedure ToggleXPStyle;
end;
procedure SHGetSetSettings(var lpss: SHELLSTATE; dwMask: DWORD; bSet: BOOL) stdcall;
external "shell32.dll";
const
SSF_SHOWALLOBJECTS = $00000001;
SSF_SHOWEXTENSIONS = $00000002;
SSF_HIDDENFILEEXTS = $00000004;
SSF_SERVERADMINUI = $00000004;
SSF_SHOWCOMPCOLOR = $00000008;
SSF_SORTCOLUMNS = $00000010;
SSF_SHOWSYSFILES = $00000020;
SSF_DOUBLECLICKINWEBVIEW = $00000080;
SSF_SHOWATTRIBCOL = $00000100;
SSF_DESKTOPHTML = $00000200;
SSF_WIN95CLASSIC = $00000400;
SSF_DONTPRETTYPATH = $00000800;
SSF_SHOWINFOTIP = $00002000;
SSF_MAPNETDRVBUTTON = $00001000;
SSF_NOCONFIRMRECYCLE = $00008000;
SSF_HIDEICONS = $00004000;
SSF_FILTER = $00010000;
SSF_WEBVIEW = $00020000;
SSF_SHOWSUPERHIDDEN = $00040000;
SSF_SEPPROCESS = $00080000;
SSF_NONETCRAWLING = $00100000;
SSF_STARTPANELON = $00200000;
SSF_SHOWSTARTPAGE = $00400000;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.btnToggleXPStyleClick(Sender: TObject);
begin
ToggleXPStyle;
end;
procedure TForm1.ToggleXPStyle;
var
lpss: SHELLSTATE;
bIsXPstyle: Boolean;
theMask: DWord;
begin
theMask:=$2;
ZeroMemory(@lpss, SizeOf(lpss));
// Retrieve current style
SHGetSetSettings(lpss, SSF_STARTPANELON, False);
// Check the current style
bIsXPstyle := (lpss.Flags2 and theMask) = theMask; // fStartPanelOn
if bIsXPstyle then // If XP style is on
lpss.Flags2 := 0 // turn it off
else // otherwise
lpss.Flags2 := theMask; // turn it on
// Set new style
SHGetSetSettings(lpss, SSF_STARTPANELON, True);
// Notify desktop of the change
PostMessage(FindWindow("Progman", nil), WM_USER + $60, 0, 0);
// Notify taskbar
PostMessage(FindWindow("Shell_TrayWnd", nil), WM_USER + $0D, 0, 0);
end;
procedure TForm1.btnToggleIconsClick(Sender: TObject);
begin
ToggleTheIcons;
end;
procedure TForm1.ToggleTheIcons;
var
lpss: SHELLSTATE;
bIsShowIcons: Boolean;
theMask: DWord;
begin
theMask:=$4000; // I have tried several different values for this!
// any value seems to turn them back on - no value seems to turn
// them off. Perhaps this is entirely the wrong way to do it?
//
ZeroMemory(@lpss, SizeOf(lpss));
// Retrieve current state
SHGetSetSettings(lpss, SSF_HIDEICONS, False);
// Check the current state of icons
bIsShowIcons := (lpss.Flags1 and theMask) = theMask; //fHideIcons
if (bIsShowIcons) then // if desktop icons are showing
lpss.Flags1 := $0000 // turn them off
else // otherwise
lpss.Flags1 := theMask; // turn them on
// Set new style
SHGetSetSettings(lpss, SSF_HIDEICONS, True);
// Notify desktop of the change
PostMessage(FindWindow("Progman", nil), WM_USER + $60, 0, 0);
end;
end.
← →
Igor_thief (2005-11-24 20:32) [1]Удалено модератором
Примечание: Создание пустых сообщений
Страницы: 1 вся ветка
Текущий архив: 2005.12.11;
Скачать: CL | DM;
Память: 0.46 MB
Время: 0.038 c