Hab's jetzt wie folgt umgesetzt:
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
ICO: TIcon;
Large, Small: HIcon;
IconIndex: Word;
buf: array[0..max_path] of char;
begin
ICO := TIcon.Create;
try
StrPCopy(buf, Edit1.Text);
IconIndex := 0;
ICO.Handle := ExtractAssociatedIcon(hInstance, buf, IconIndex);
SpeedButton1.Glyph.Width := 0;
SpeedButton1.Glyph.Height := 0;
SpeedButton1.Glyph.Width := ICO.Width;
SpeedButton1.Glyph.Height := ICO.Height;
SpeedButton1.Glyph.Canvas.Draw(0, 0, ICO);
//SpeedButton1.Refresh;
finally
ICO.Free;
end;
end;
... und Bild wieder entfernen:
Delphi-Quellcode:
procedure TForm1.ButtonResetClick(Sender: TObject);
begin
SpeedButton1.Glyph := nil;
end;
Die Bildqualität ist teilweise aber ziehmlich mies (ist mir bei vorherigen Versuchen gar nicht so aufgefallen).
Kann man da noch was machen, die sollten eigentlich so ausschauen wie z.B. auf dem Desktop.