Original Post
🔒 Locked
Icon selector
Advertisement
You need an image list. After that, you attach the image list to the list box.
---------------------------------------------
"Love is a disease"
---------------------------------------------
"Love is a disease"
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]
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement
