有关于动态定SHAPE的问题??

guxingke 2004-09-17 09:26:22
我还想问一下各位,如果是一组动态的创建的parnel.和一组动态创建的SHAPE,二者创建的时间不是一定是同时的,当然panel肯定是在shape之前创建的,就是说要指明哪明某个SHAPE的PARENT是谁要怎么做?? 比如有若干个车间,每个车间有若干个机器,我用PANEL代表车间,用SHPAE代表机器,所以当我在车间一里增加机器时,那个shape的PARENT就要是车间一的对应的那个PANEL对吧

...全文
87 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
guxingke 2004-09-21
  • 打赏
  • 举报
回复
怎么没有人回答了, 自己顶!!!
guxingke 2004-09-20
  • 打赏
  • 举报
回复
to cscer:
能不能具体一点
guxingke 2004-09-18
  • 打赏
  • 举报
回复
to zhaohui_1981用了人的办法还是不行的,还是看不到创建后的SHAPE
to 无风雪亦飘 我的SHAPE和PANEL不是同一个时候创建的
cscer 2004-09-18
  • 打赏
  • 举报
回复
给Shape赋Parent值时先检查一下Panel是否存在

不存在的话实例化一个先
cscer 2004-09-17
  • 打赏
  • 举报
回复
不错

已经满足需求了
wilowind 2004-09-17
  • 打赏
  • 举报
回复
创建shape后
shape.parent := panel
wilowind 2004-09-17
  • 打赏
  • 举报
回复
创建 Panel时 把panel的tag设置为 车间的id .
创建shape时, 搜索机器所在车间id ,就得到panel 的tag了.
然后遍历比较tag
minjunw 2004-09-17
  • 打赏
  • 举报
回复
在创建shape后,将它的parent属性赋上对应的Panel就好
zhaohui_1981 2004-09-17
  • 打赏
  • 举报
回复
shape := tshape.Create(your panel);
guxingke 2004-09-17
  • 打赏
  • 举报
回复
以上的代码不太清楚我删了一些你们看这个可能比较好点:
procedure TmainF.AddNodeClick(Sender: TObject);
var
noname: string;
panelname: string;
shapename: string;
panelno: integer;
ii: integer;
begin
selectnode := TreeView1.Selected;
nonode := TreeView1.Selected.Count; //(0<count<999)
panelno := 0;
if (selectnode.Text = '´óÔ²»ú') then begin //这也只是一个添加nonode_name 的地方
noname := '³µ¼ä' + inttostr(nonode + 1);
try
begin
panelname := 'panel' + inttostr(nonode + 1);
panel[panelno] := tpanel.Create(RzPanel1); //Ìí¼ÓSHAPE
with panel[panelno] do begin
parent := mainF;
name := panelname;
left := 208;
TOP := 32;
height := 500;
width := 585;
BEVeLOUTER := BVLOWERED;
color := clCaptionText;
// visible:=false;
end;
end;
except
showmessage('Ìí¼Ó½Úµã³ö´í£¬ÇëÈ·ÈϺóÌí¼Ó£¡');
end;
end
else if (selectnode.parent.Text = '´óÔ²»ú') then begin
nonode_name:= //这儿只是一个添加nonode_name 的地方
end;
try
begin
shapename := copy(noname, 2, length(noname) - 1);
shape := tshape.Create(self);
with shape do begin
parent := panel[nonode + 1];
// parent:=self;
name := shapename;
left := 30;
TOP := 30;
height := 300;
width := 300;
shape := stCircle;
brush.color := cllime;
brush.Style := bssolid;
end;
// showmessage(panel[nonode+1].Parent.name );
TreeView1.Items.AddChild(selectnode, noname);
end;
except
showmessage('½ÚµãÌí¼Ó³ö´í£¬ÇëÈ·ÈϺóÌí¼Ó£¡');
end;
end;
end;
我的PANEL和shape 不是同时创建的,所以把shape定父亲的时候老是出错。
guxingke 2004-09-17
  • 打赏
  • 举报
回复
我想要把那些SHAPE放到panel上呀,我创建SHAPE后,无法将其放到PANEL上,
procedure TmainF.AddNodeClick(Sender: TObject);
var
selectnode: TTreeNode; //±»Ñ¡ÔñµÄ½Úµã
shape: tshape;
nonode: integer; //½Úµã±¾ÉíµÄºÅÊý
noname: string; //½ÚµãÃû³Æ
sqlstr: string; //sql ÊäÈëÓï¾ä
chileno: integer; //Ô­½ÚµãÖÐ×Ó½ÚµãµÄ¸öÊý
panelname: string;
shapename: string;
node_id: integer; //µ±Ç°½ÚµãµÄºÅÂë
panelno: integer;
ii: integer;
begin
selectnode := TreeView1.Selected;
nonode := TreeView1.Selected.Count; //(0<count<999)
panelno := 0;
// if (selectnode.Text = '´óÔ²»ú') or (selectnode.Parent.Text = '´óÔ²»ú') then begin
if (selectnode.Text = '´óÔ²»ú') then begin //Ìí¼Ó³µ¼äºÅ
noname := '³µ¼ä' + inttostr(nonode + 1);
try
begin
panelname := 'panel' + inttostr(nonode + 1);

panel[panelno] := tpanel.Create(RzPanel1); //Ìí¼ÓSHAPE
with panel[panelno] do begin
parent := mainF;
name := panelname;
left := 208;
TOP := 32;
height := 500;
width := 585;
BEVeLOUTER := BVLOWERED;
color := clCaptionText;
// visible:=false;
end;
end;
except
showmessage('Ìí¼Ó½Úµã³ö´í£¬ÇëÈ·ÈϺóÌí¼Ó£¡');
end;
end
else if (selectnode.parent.Text = '´óÔ²»ú') then begin
if (nonode > 8) and (nonode <= 98) then begin //Èç¹ûÉ豸̨Êý´óÓÚ9̨СÓÚµÈÓÚ98
if (length(selectnode.Text) = 5) then //³µ¼äºÅ¡´9
noname := 'NO' + '0' + copy(selectnode.Text, length(selectnode.Text), 1) + '0' + inttostr(nonode + 1)
else if (length(selectnode.Text) = 6) then //³µ¼äºÅ>9
noname := 'NO' + copy(selectnode.Text, length(selectnode.Text) - 1, 2) + '0' + inttostr(nonode + 1);
end
else if nonode <= 8 then begin //Èç¹ûÉ豸̨ÊýСÓÚ9̨
if (length(selectnode.Text) = 5) then //³µ¼äºÅ¡´9
noname := 'NO' + '0' + copy(selectnode.Text, length(selectnode.Text), 1) + '00' + inttostr(nonode + 1)
else if (length(selectnode.Text) = 6) then //³µ¼äºÅ>9
noname := 'NO' + copy(selectnode.Text, length(selectnode.Text) - 1, 2) + '00' + inttostr(nonode + 1);
end
else if nonode > 98 then begin //Èç¹ûÉ豸̨Êý´óÓÚ98̨
if (length(selectnode.Text) = 5) then //³µ¼äºÅ¡´9
noname := 'NO' + '0' + copy(selectnode.Text, length(selectnode.Text), 1) + inttostr(nonode + 1)
else if (length(selectnode.Text) = 6) then //³µ¼äºÅ>9
noname := 'NO' + copy(selectnode.Text, length(selectnode.Text) - 1, 2) + inttostr(nonode + 1);
end;
try
begin
shapename := copy(noname, 2, length(noname) - 1);
shape := tshape.Create(self);
with shape do begin
parent := panel[nonode + 1];
// parent:=self;
name := shapename;
left := 30;
TOP := 30;
height := 300;
width := 300;
shape := stCircle;
brush.color := cllime;
brush.Style := bssolid;
end;
// showmessage(panel[nonode+1].Parent.name );
end;
except
showmessage('½ÚµãÌí¼Ó³ö´í£¬ÇëÈ·ÈϺóÌí¼Ó£¡');
end;
end;
end;
这是我创建SHAPE和panel的代码,请各位看看现在shape有创建,可是看不到,为什么呢?????

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧