WinAPI: LoadIcon - 从资源中载入图标

//声明:
LoadIcon(
  hInstance: HINST; {EXE 或 DLL 的句柄, 0 表示载入系统资源}
  lpIconName: PChar {资源标识符}
): HICON;           {返回图标句柄}

 
 
 
 
 

 

 
  
这里有示例
//调用系统图标的例子:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  ico: TIcon;
  i,x: Integer;
begin
  ico := TIcon.Create;
  x := 10;
  for i := 32512 to 32517 do
  begin
    ico.Handle := LoadIcon(0, MakeIntResource(i));
    Canvas.Draw(x,10,ico);
    Inc(x,ico.Width+10);
  end;
  ico.Free;
end;

end.

 
 
 
 
 

 

 
  

//效果图:
WinAPI: LoadIcon - 从资源中载入图标
//附系统图标列表:
IDI_APPLICATION = MakeIntResource(32512);
IDI_HAND        = MakeIntResource(32513);
IDI_QUESTION    = MakeIntResource(32514);
IDI_EXCLAMATION = MakeIntResource(32515);
IDI_ASTERISK    = MakeIntResource(32516);
IDI_WINLOGO     = MakeIntResource(32517);
IDI_WARNING     = IDI_EXCLAMATION;
IDI_ERROR       = IDI_HAND;
IDI_INFORMATION = IDI_ASTERISK;

 
 
 
 
 

 

 
  

你可能感兴趣的:(WinAPI: LoadIcon - 从资源中载入图标)