Skip to main content
GameDev.net gamedev.net
🔒 Locked

Icon selector

Started by TheSorcerer Jan 19, 2003 at 7:27 AM 1 replies 200+ views
Original Post
TheSorcerer
TheSorcerer
I''m trying to create an icon selector windows. Like this one: Is this a Common Dialog? If not then I have another question. I have a list box that shows icons. How do I put those icons in there?
nes8bit
nes8bit
You need an image list. After that, you attach the image list to the list box.

---------------------------------------------
"Love is a disease"
Michalson
Michalson
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]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.