我写了一个自定义组件,用Componet-->install component提示注册成功,可怎么找不到呢?代码如下:
unit PickIcon;interface
uses
Windows, Messages, SysUtils, Classes, Graphics,
Controls,extctrls,ShellAPI,Forms;
type
TPickIcon=class(TCustomControl)
private
        Image:TImage;
        FFileName:String;
        FTotal:Integer;
        FIconIndex:Integer;
        procedure SetFileName(file_name:string);
        procedure ChangeIconIndex(I:Integer);
public        procedure GetIcon(var AnIcon:TIcon;Index:Integer);
        procedure SaveIconAs(Name:string);
        constructor Create(AOwner:TComponent);Override;
published
        property Total:Integer read FTotal;
        property FileName:string read FFileName write SetFileName;
        property IconIndex:integer read FIconIndex write ChangeIconIndex;
end;
procedure register;
implementation
procedure register;
begin
  RegisterComponents('Samples',[TPickIcon]);
end;
constructor TPickIcon.Create(AOwner:TComponent);
begin
  Inherited;
  //限制控件的大小
  Self.Constraints.MaxHeight :=34;
  Self.Constraints.MaxWidth :=34;
  Self.Constraints.MinHeight :=34;
  Self.Constraints.MinWidth :=34;  Image:=TImage.Create(self);
  Image.Parent:=self;
  Image.Left:=0;
  Image.Top:=0;
  Image.Width:=34;
  Image.Height:=34;
end;
procedure TPickIcon.SetFileName(file_name:string);
begin
  Image.Picture:=nil;
  FFileName:=file_name;
  FTotal:=ExtractIcon(hInstance,PChar(file_name),LongWord(-1));
  IconIndex:=0;
  //Application.MessageBox(FFileName,'ddd');
end;
procedure TPickIcon.GetIcon(var AnIcon:TIcon;Index:Integer);
begin
  if(Index>=Total) or (index<0) then AnIcon.Handle:=0
  else
     AnIcon.Handle:=ExtractIcon(hInstance,PChar(FFileName),Index);
end;
procedure TPickIcon.ChangeIconIndex(I:integer);
begin
  if I>=total then FIconIndex:=Total-1
  else if I<0 then FIconIndex:=0
  else FIconIndex:=I;
  if Total=0 then exit;
  Image.Picture.Icon.Handle:=ExtractIcon(hInstance,PChar(FFileName),FIconIndex);
end;
procedure TPickIcon.SaveIconAs(Name:string);
begin
  if FIconIndex<0 then exit;
  image.Picture.SaveToFile(name);
end;
end.