component-->Install component 提示安裝成功﹐為什么沒有控件出來呢? ( 积分: 50 )

  • 主题发起人 主题发起人 胡圖崇
  • 开始时间 开始时间

胡圖崇

Unregistered / Unconfirmed
GUEST, unregistred user!
我編寫一個控件后﹐進行﹕component-->Install component 提示安裝成功﹕Package:c:/borland/..../XXX.bpl has been installed
雖然提示成功了﹐但是在組件欄上看不到我的控件﹐然后我查看了component-->install package對應的bpl﹐單擊component按鈕﹐發現里面沒有控件﹐不知道什么原因﹐請高手指點。

代碼如下﹕
unit DropListBox;

interface

uses windows,classes,ExtCtrls,Messages,Graphics,controls,StdCtrls,ShellApi;

type TmynotifyEvent=procedure (sender:Tobject;filenames:TstringList) of object;

type TDropListBox=class(TlistBox)
private
fondrop:TmynotifyEvent;
fenabled:bool;
procedure dropfiles(var Msg:TMsg);message WM_DROPFILES;
procedure setenabled(benabled:bool);
public
constructor create(Aowner:Tcomponent);override;
published
property ondropfile:TmynotifyEvent read fondrop write fondrop;
property ffenabled:bool read fenabled write setenabled;
end;

procedure register;

implementation

{ TDropListBox }

procedure register;
begin
registercomponents('Hooton',[TDropListBox]);
end;
constructor TDropListBox.create(Aowner: Tcomponent);
begin
inherited create(Aowner);
fenabled:=true;
end;

procedure TDropListBox.dropfiles(var Msg: TMsg);
var filenames:Tstringlist;
filename:array[0..255] of char;
fcount,i:integer;
begin
filenames:=Tstringlist.create();
fcount:=DragQueryFile(Msg.wparam,$FFFFFFFF,@filename,Max_path);
for i:=0 to fcount do
begin
dragQueryfile(msg.wparam,i,filename,max_path);
filenames.add(filename);
end;
dragfinish(msg.wparam);
if assigned(fondrop) then
fondrop(self,filenames);
filenames.free;

end;

procedure TDropListBox.setenabled(benabled: bool);
begin
fenabled:=benabled;
DragAcceptFiles(Handle,benabled);
end;

end.
 
我編寫一個控件后﹐進行﹕component-->Install component 提示安裝成功﹕Package:c:/borland/..../XXX.bpl has been installed
雖然提示成功了﹐但是在組件欄上看不到我的控件﹐然后我查看了component-->install package對應的bpl﹐單擊component按鈕﹐發現里面沒有控件﹐不知道什么原因﹐請高手指點。

代碼如下﹕
unit DropListBox;

interface

uses windows,classes,ExtCtrls,Messages,Graphics,controls,StdCtrls,ShellApi;

type TmynotifyEvent=procedure (sender:Tobject;filenames:TstringList) of object;

type TDropListBox=class(TlistBox)
private
fondrop:TmynotifyEvent;
fenabled:bool;
procedure dropfiles(var Msg:TMsg);message WM_DROPFILES;
procedure setenabled(benabled:bool);
public
constructor create(Aowner:Tcomponent);override;
published
property ondropfile:TmynotifyEvent read fondrop write fondrop;
property ffenabled:bool read fenabled write setenabled;
end;

procedure register;

implementation

{ TDropListBox }

procedure register;
begin
registercomponents('Hooton',[TDropListBox]);
end;
constructor TDropListBox.create(Aowner: Tcomponent);
begin
inherited create(Aowner);
fenabled:=true;
end;

procedure TDropListBox.dropfiles(var Msg: TMsg);
var filenames:Tstringlist;
filename:array[0..255] of char;
fcount,i:integer;
begin
filenames:=Tstringlist.create();
fcount:=DragQueryFile(Msg.wparam,$FFFFFFFF,@filename,Max_path);
for i:=0 to fcount do
begin
dragQueryfile(msg.wparam,i,filename,max_path);
filenames.add(filename);
end;
dragfinish(msg.wparam);
if assigned(fondrop) then
fondrop(self,filenames);
filenames.free;

end;

procedure TDropListBox.setenabled(benabled: bool);
begin
fenabled:=benabled;
DragAcceptFiles(Handle,benabled);
end;

end.
 
自己新建一个Package,然后把pas加进去,然后Install,把这个bpl加载起来看看
 
加載了﹐component-->install component-->into new package﹐編譯安裝后﹐bpl會自動加載的﹐然后我選擇對應的bpl﹐單擊component按鈕查看﹐發現此bpl沒控件。
 
register -> Register,注意大小写!
 
謝謝dreamisx
改成大寫真的可以
暈﹐Delphi中還要區分大小寫啊?
 
http://www.delphibbs.com/delphibbs/dispq.asp?LID=106355
标题是: 为何我写的控件装不上?(简单,快来)

居然一模一样
 
的确是这样,Register之所以区分大小写据说是为了C++Builder兼容(因C++Builder中只认Register)。
 
多人接受答案了。
 
后退
顶部