Link to home
Start Free TrialLog in
Avatar of MonkeyLin
MonkeyLin

asked on

How to display the Change Icon Dialog in delphi?

ASKER CERTIFIED SOLUTION
Avatar of Member_2_248744
Member_2_248744
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of simonet
listening...
I spotted a potential memory leak, this should be better

procedure TForm1.button1Click(Sender: TObject);
var
PName: PChar;
MaxFl,IcoIndex: Cardinal;
NumIcon: Integer;
hLIcon, hSIcon: THandle;
begin
if OpenDialog1.Execute then
  begin
  GetMem(PName, 1024);
  try
    StrCopy(PName, PChar(OpenDialog1.FileName));
    MaxFl := 1023;
    IcoIndex := 0;
    if not PickIconDlg(Handle, PName, MaxFl, @IcoIndex) then
      Exit;
   NumIcon := ExtractIconEx(PName, IcoIndex, hLIcon, hSIcon, 1);
   finally
   FreeMem(PName);
   end;
DrawIcon(Canvas.Handle,250,43, hLIcon);
end;
Avatar of MonkeyLin
MonkeyLin

ASKER

Slick812, thank you!!!
^-^