本人已经写好一个控件,在加载到FORM里时,出现错误:Control" has no parent window.请问怎样解决这个问题(自定义控件的父类是TListView)?解决后马上给分!!!
解决方案 »
- 请问Groupbox的标题有没有居中的属性
- delphi listview 读取写入ini~~
- 新手请求各位大侠支援,帮我看看这儿错在哪了!!!!!!!!!!!!!
- 基础扫盲:请问什么是接口
- 抢分问题:delphi中的编译和生成(compile & build)有何区别呀? (2)
- 怎么在WWDBGrid中将数据库中的以二进制形式保存的JPG格式图片显示出来??? 急急急!!!在线等!!!
- 《设计模式Delphi版》的怪问题!!!!
- 需要说明文档的中文版
- 一道面试题!帮帮我!!!
- 哪有Delphi6的Update 1或 2 下载
- DBGridEh里面如何让在按回车的时候在一个一个Cell里面浏览?
- DCOMCNFG怎样配置才能发布利用DCOMConnection连接的分布式应用程序?
constructor Create(AOwner: TComponent);override;constructor TMyListView.Create(AOwner: TComponent);
begin
//自己添加的内容
...............
//
inherirted;
end;
var
templi: Tlistitem;
tempbmp: Tbitmap;
strDir,Dir:string;
f:TSearchRec;
FileName:String;
i:integer;
// imagelist:TImageList;
// listname:TComponentName;
begin
inherited Create(AOwner);
clear;
FImageChangeLink := TChangeLink.Create;
FImages:= TCustomImageList.Create(Self);
FImages.height:=70;
FImages.width:=70;
strDir:='e:/bmp/';
if strDir[Length(strDir)]<>'/' then
strDir:=strDir+'/'
else
Dir:=strDir+'*.bmp'; if FindFirst(Dir,faAnyFile,f)=0 then
begin
i:=0;
repeat
strDir:='e:/bmp/';
FileName:=f.Name;
strDir:=strDir+FileName;
templi:= self.Items.Add;
templi.Caption:=FileName;
tempbmp:=Tbitmap.Create;
tempbmp.LoadFromFile(strDir); //加载位图
tempbmp.Canvas.StretchDraw(Rect(0,0,70,70),tempbmp); //缩放位图
FImages.add(tempbmp,nil);
FImages.Replace(i,tempbmp,nil); //释放图片
templi.ImageIndex:= i;
i:=i+1;
tempbmp.Free; //释放位图
until FindNext(f)<>0;
findclose(f);
end;
end;
请问PARENT怎么指定
FImageChangeLink := TChangeLink.Create;
FImages:= TCustomImageList.Create(Self);
FImages.GetParentComponent; //添加的语句但是结果还是同样的错误,请问应该怎样指定FImages的Parent呢?谢谢!
procedure SetParent(AParent: TWinControl); override;procedure TImageListView.SetParent(AParent: TWinControl);
begin
inherited SetParent(AParent);
//将Create中一些代码移到这里来,这时候已经有了Paren。
end;—————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
—————————————————————————————————
procedure TImageListView.SetParent(AParent: TWinControl);
begin
inherited SetParent(AParent);
FImageChangeLink := TChangeLink.Create;
FImages:= TCustomImageList.Create(Self);
FImages.SetSubComponent(true);
FImages.height:=70;
FImages.width:=70;
end;
但是还是出现相同的错误,请指教,谢谢!
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
—————————————————————————————————