如何在show窗口时只show出一个?

guguda 2002-07-15 12:37:02
是这样的,当在form里找打开其他form时,我在点菜单时使用了:
form:=tform.Create(self);
form.show
这样一个窗口就打开了,但是但再次运行时又打开了一个同样的窗口,我要怎么做才能在已打开这个窗口后再运行时不再打开新的窗口而是让焦点放到这个已运行的窗口上?
...全文
78 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhhahuatian 2002-07-15
  • 打赏
  • 举报
回复
up
coolmer 2002-07-15
  • 打赏
  • 举报
回复
if not nill(form) then
form.show
else
begin
form:=tform.Create(self);
form.show
end;
tonny123 2002-07-15
  • 打赏
  • 举报
回复
同意 up楼上的。
yansea 2002-07-15
  • 打赏
  • 举报
回复
if not assigned(form2) then
begin
form2:=tform2.Create(self);
form2.show
end; //这样没有问题,但是在form的close要写
action := acfree; //窗体释放;
destory里要写
form2 := nil;//让它在内存中消失
yansea 2002-07-15
  • 打赏
  • 举报
回复
if not assigned(form2) then
begin
form2:=tform2.Create(self);
form2.show
end; //这样没有问题,但是在form的close要写
action := acfree; //窗体释放;
destory里要写
form2 := nil;//让它在内存中消失
lyfzjl 2002-07-15
  • 打赏
  • 举报
回复
最好用模式窗口,就是form.showmodel.
johnsonrao 2002-07-15
  • 打赏
  • 举报
回复
form.ShowModal;
cqbonny 2002-07-15
  • 打赏
  • 举报
回复
设置一个标志把
树_皮 2002-07-15
  • 打赏
  • 举报
回复
if not assigned(form) then
begin
form:=tform.Create(self);
form.show
end
else
exit;
很土 2002-07-15
  • 打赏
  • 举报
回复
假设主窗口为 Form1, 子窗口为 Form2,则有:

if not Assigned(Form2) then
Form2 := TForm2.Create(Self);
Form2.Show;
BringWindowToTop(Form2.Handle); // 放到最前面来

试试?

5,930

社区成员

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

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