I've written a program that allows me to launch other applications from it by having it dynamically generate buttons based on information in inifiles. I wrote it to get rid of the gazzillion shortcuts on my desktop. This all works just fine.
But now I've gotten it in my head that I want to buttons to show glyphs, so when I select a program (using a simple opendialog) I want to extract the icon, resize it to 16x16 if neccesary and save it as a bmp file.
I know how to extract an Icon:
And I know how to resize a file:
The problem lies in that I cannot for the life of me get these two to work together. Can anyone clue me in?
BobbaFet ![[bobafett] [bobafett] [bobafett]](/data/assets/smilies/bobafett.gif)
But now I've gotten it in my head that I want to buttons to show glyphs, so when I select a program (using a simple opendialog) I want to extract the icon, resize it to 16x16 if neccesary and save it as a bmp file.
I know how to extract an Icon:
Code:
var MyIcon: TIcon;
begin
if OpenDialog1.Execute then
begin
Edit1.Text := OpenDialog1.FileName;
MyIcon := TIcon.Create;
MyIcon.Handle := ExtractIcon(hInstance, PChar(OpenDialog1.FileName), 0);
Image1.Canvas.Draw(0,0,MyIcon);
MyIcon.Free;
end;
end;
And I know how to resize a file:
Code:
const
maxWidth = 200;
maxHeight = 150;
var
thumbnail : TBitmap;
thumbRect : TRect;
begin
thumbnail := Form1.GetFormImage;
try
thumbRect.Left := 0;
thumbRect.Top := 0;
//proportional resize
if thumbnail.Width > thumbnail.Height then
begin
thumbRect.Right := maxWidth;
thumbRect.Bottom := (maxWidth * thumbnail.Height) div thumbnail.Width;
end
else
begin
thumbRect.Bottom := maxHeight;
thumbRect.Right := (maxHeight * thumbnail.Width) div thumbnail.Height;
end;
thumbnail.Canvas.StretchDraw(thumbRect, thumbnail) ;
//resize image
thumbnail.Width := thumbRect.Right;
thumbnail.Height := thumbRect.Bottom;
//display in a TImage control
Image1.Picture.Assign(thumbnail) ;
finally
thumbnail.Free;
end;
end;
The problem lies in that I cannot for the life of me get these two to work together. Can anyone clue me in?
![[bobafett] [bobafett] [bobafett]](/data/assets/smilies/bobafett.gif)
![[bobafett] [bobafett] [bobafett]](/data/assets/smilies/bobafett.gif)
Code:
if not Programming = 'Severe Migraine' then
ShowMessage('Eureka!');