Select a icon from file ( Shell style )

Hi friends;

I need a undocumented api to call the select icon dialog( Change Icon button from shortcut properties ) to return a file/index icon resource.
If not exists, a replacement is welcomed too

T++, Radler.
LVL 4
RadlerAsked:
Who is Participating?
 
intheConnect With a Mentor Commented:
hi radler,
i have a component that does the shelldiaogs and gives you about 10 more system dialogs to call including the icon picker one.
leave your email address and i send you.

Regards Barry
0
 
intheCommented:
have sent to this address :
roger@ars.com.br

hope that ok .
cheers Barry
0
 
intheCommented:
there is also another way to extract the icons without using the icon dialog which example is here:

http://www.drdelphi.com/delphi/right/tips/Listicons.htm
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
DrDelphiCommented:
inthe,
  that code looks very familiar to me for some reason.... <G>

0
 
kretzschmarCommented:
hi barry,

can you forward the component to me too?
meikl@spektracom.de

meikl
0
 
intheCommented:
hi all,
 have sent you comps also meikl,
tell me what you think of them ;-)
cheers Barry
0
 
RadlerAuthor Commented:
Hi Inthe,

Really you give a great help, above desired.
I tried use this
unit IconDlg;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, ShellAPI;

type
      TIconDlg = class(TComponent)
      private
            FIcon: TIcon;
            FFileName: String;
            FIndex: Integer;
            function GetAnyFile: String;
      public
            constructor Create(AOwner: TComponent); override;
            destructor Destroy; override;
            function Execute: Boolean;
            property Icon: TIcon read FIcon;
      published
            property FileName: String read FFileName write FFileName;
            property IconIndex: Integer read FIndex write FIndex;
      end;

procedure Register;

implementation

//##### NOTA : O macete para chamar este API nao documentada e o indice de chamada da DLL 63 !!!!!!

function PickIconDlgA( OwnerWnd: HWND; lpstrFile: PAnsiChar; var nMaxFile: LongInt;
                                    var lpdwIconIndex: LongInt): LongBool stdcall; external 'SHELL32.DLL' index 63;
                                    
//##### NOTA : O macete para chamar este API nao documentada e o indice de chamada da DLL 63 !!!!!!

constructor TIconDlg.Create(AOwner: TComponent);
begin
      inherited Create(AOwner);
      FIcon := TIcon.Create;
end;

destructor TIconDlg.Destroy;
begin
      FIcon.Free;
      inherited Destroy;
end;

function TIconDlg.Execute: Boolean;
var
      zFileName: array [0..MAX_PATH - 1] of Char;
      zSize, zIndex: LongInt;
begin
       zSize := MAX_PATH;
       StrPCopy(zFileName,GetAnyFile);
       if FileName <> '' then begin
            StrPCopy(zFileName,FileName);
       end;
       Result := PickIconDlgA(0,zFilename,zSize,zIndex);
       FileName := StrPas(zFileName);
       IconIndex := zIndex;
       if (FileName <> '') and (IconIndex <> -1) then begin
            FIcon.Handle := ExtractIcon(hInstance,zFileName,zIndex);
       end;
end;

//NOTE: GetAnyFile is for getting SHELL32.DLL if no filename is specified on startup becuase PickIconDlgA requires one.

function TIconDlg.GetAnyFile: String;
var
      zSysDir: array [0..MAX_PATH - 1] of Char;
      SysDir: String;
begin
       GetSystemDirectory(zSysDir,255);
       SysDir := StrPas(zSysDir);
       if SysDir[Length(SysDir)] <> '\' then begin
            SysDir := SysDir + '\';
       end;
       Result := SysDir + 'SHELL32.DLL';
end;

procedure Register;
begin
      RegisterComponents('Super', [TIconDlg]);
end;

end.

and the result was the standard fileopendlg.
Now i'm testing your code.
To more 10 points, where you get it ?

T++, Radler.
0
 
intheCommented:
Hi Radler ,this took much thinking as i could'nt remember where i found them but at last i got it :

http://www.delphimag.com/features/1999/05/di199905kb_f/di199905kb_f.asp

also a good explanation etc there.
Regards Barry
0
 
intheCommented:
above link was part 2,
this is part 1 of the article:

http://www.delphimag.com/features/1999/03/di199903kb_f/di199903kb_f.asp
0
 
RadlerAuthor Commented:
Adjusted points to 65
0
 
RadlerAuthor Commented:
Greate help.
When the Brazilian slavery finish, we take a beer at the beach.

T++, Radler.
0
 
intheCommented:
hehe cool ;-)
0
All Courses

From novice to tech pro — start learning today.