Thread View: borland.public.delphi.nativeapi
2 messages
2 total messages
Started by Damitr
Tue, 15 Nov 2005 00:31
Using SHGetSetSettings to emulate XPs Show Desktop Icons switch
Author: Damitr
Date: Tue, 15 Nov 2005 00:31
Date: Tue, 15 Nov 2005 00:31
133 lines
4377 bytes
4377 bytes
In Win XP you can right click on the desktop, select "Arrange Icons by"
then check or uncheck "Show Desktop Icons". I need to emulate this
function programatically. An old thread gave me a clue about using
SHGetSetSettings - but I've gotten stuck. The code below (attached to
a form with a button called btnToggleIcons) gives a "Types of actual
and formal var parameters must be identical" error. But I've tried
every variation I can think of and all I can succeed in doing is
varying the error messages <S>
Can anyone fix my code for me?
************************************
unit uIcons;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs,
StdCtrls, shlobj;
type
TShellRecord = packed record
fShowAllObjects: bool;
fShowExtensions: bool;
fNoConfirmRecycle: bool;
fShowSysFiles: bool;
fShowCompColor: bool;
fDoubleClickInWebView: bool;
fDesktopHTML: bool;
fWin95Classic: bool;
fDontPrettyPath: bool;
fShowAttribCol: bool;
fMapNetDrvBtn: bool;
fShowInfoTip: bool;
fHideIcons: bool;
fWebView: bool;
fFilter: bool;
fShowSuperHidden: bool;
fNoNetCrawling: bool;
dwWin95Unused: DWORD;
uWin95Unused: UINT;
lParamSort: longint;
iSortDirection: integer;
version: UINT;
uNotUsed: UINT;
fSepProcess: bool;
fStartPanelOn: bool;
fShowStartPage: bool;
fSpareFlags: UINT;
end;
PShellRecord = ^TShellRecord;
TForm1 = class(TForm)
btnToggleIcons: TButton;
procedure btnToggleIconsClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
{TShellFlagState is already defined in shlobj.pas}
procedure SHGetSetSettings(var lpss: TShellFlagState; dwMask: DWORD;
bSet:
BOOL); stdcall;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure SHGetSetSettings; external 'shell32.dll' name
'SHGetSetSettings'
procedure TForm1.btnToggleIconsClick(Sender: TObject);
var
psr: PShellRecord;
msk: cardinal;
bset: longbool;
begin
bset:=false;
SHGetSetSettings(psr, msk, bset);
psr^.fHideIcons:= not psr^.fHideIcons;
bset:=true;
SHGetSetSettings(psr,msk,bset);
end;
end.
>From Microsoft:
SHELLSTATE Structure
Contains settings for the Shell's state. This structure is used with
the SHGetSetSettings function.
Syntax
typedef struct {
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;
DWORD dwWin95Unused;
UINT uWin95Unused;
LONG lParamSort;
int iSortDirection;
UINT version;
UINT uNotUsed;
BOOL fSepProcess:1;
BOOL fStartPanelOn:1;
BOOL fShowStartPage:1;
UINT fSpareFlags:13;
} SHELLSTATE, *LPSHSHELLSTATE;
Structure Information
Header shlobj.h
Re: Using SHGetSetSettings to emulate XPs Show Desktop Icons switch
Author: Riki Wiki
Date: Sat, 19 Nov 2005 11:49
Date: Sat, 19 Nov 2005 11:49
11 lines
1173 bytes
1173 bytes
Hoi Damitr FYI this newsgroup do not officially exist, that is why there is so few posts and so few viewers here. The newsgroup you should use is b.p.d.nativeapi.win32, and you need to post to the Borland news groups server. Take a look here: <http://tinyurl.com/8m5nw> which links to <http://delphi.wikicities.com/wiki/Delphi_Newsgroups>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads