Archived

This topic is now archived and is closed to further replies.

TheSorcerer

Icon selector

Recommended Posts

Yes, it is a common dialog. If you give me a few minutes I mind be able to post some code.

Code:


    
//Import a function from the shell32.dll

function PickIconDlgA(OwnerWnd: HWND; PFileName: PAnsiChar; var FileNameBufferLength: Integer; var lpdwIconIndex: Integer): LongBool; stdcall; external 'SHELL32.DLL' index 62;

procedure TForm1.Button1Click(Sender: TObject);
var
FileName:array[0..1000-1] of Char;
//32bit signed integers

FileNameBufferLength, Index: Integer;
begin
FileNameBufferLength:=1000;
//Set to whatever file you want to open

StrPCopy(FileName,'c:\winnt\system\system32.dll');
//Set to whatever index you want (index is zero based, and determines which icon in the file is selected

Index:=10;
if PickIconDlgA(0,FileName,FileNameBufferLength,Index) then
begin
//User picked an icon

//Filename has the name of the file the icon is in

//Index has the index within the file

//You can now use ExtractIcon or ExtractIconEX to get it

end;
end;


EDIT: Just to make it clear how the Delphi syntax works. The second parameter, FileName, is being passed as a *pointer* to the array, not the array itself. Hopefully that avoids some confusion

[edited by - michalson on January 19, 2003 8:58:28 AM]

Share this post


Link to post
Share on other sites