扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
图1 添加组件后的窗体 |
procedure TfrmMain.btnOpenClick(Sender: TObject); var i: Integer; Large, Small: HICON; nIcons: Integer; begin if OpenDialog1.Execute then begin self.Image1.Canvas.Refresh; nIcons:=ExtractIconEx(PChar(OpenDialog1.FileName), -1, Large, Small, 1); for i:=0 to nIcons-1 do begin ExtractIconEx(PChar(self.OpenDialog1.FileName), i, Large, Small, 1); DrawIcon(self.Image1.Canvas.Handle,(i div 4)*40,(i mod 4)*40,Large); end; end; end; |
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ShellAPI, Grids, ExtCtrls; type TfrmMain = class(TForm) btnOpen: TButton; OpenDialog1: TOpenDialog; Image1: TImage; procedure btnOpenClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var frmMain: TfrmMain; implementation {$R *.dfm} procedure TfrmMain.btnOpenClick(Sender: TObject); var i: Integer; Large, Small: HICON; nIcons: Integer; begin if OpenDialog1.Execute then begin self.Image1.Canvas.Refresh; nIcons:=ExtractIconEx(PChar(OpenDialog1.FileName), -1, Large, Small, 1); for i:=0 to nIcons-1 do begin ExtractIconEx(PChar(self.OpenDialog1.FileName), i, Large, Small, 1); DrawIcon(self.Image1.Canvas.Handle,(i div 4)*40,(i mod 4)*40,Large); end; end; end; end. |
图2 程序运行的初始画面 图3 程序运行结果 |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者