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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

intheCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.