我在Delphi 10中编码。我有两种形式:FormPrincipal
,它是主要形式,Formbanco
是我想要调用的形式。
在FormPrincipal
我添加了一个小组PanelCorpo
,我想致电Formbanco
并将其显示在此小组的位置。
我尝试过两种方法,但两种方法都不起作用。见下文:
FormPrincpal
使用Formbanco
:Showmodal
// TActionlist OnExecute event
procedure TFormPrincipal.AbreFormBancoExecute(Sender: TObject);
begin
try
Application.CreateForm(Tformbanco,Formbanco);
Formbanco.Parent := PanelCorpo;
Formbanco.Align := alclient;
Formbanco.Showmodal;
finally
Freeandnil(formbanco);
end;
end;
行为是:它正确地打开了被调用的表单Formbanco
,但是已经冻结了。两种形式都不允许关注!
Show
调用Formbanco:// TActionlist OnExecute event
procedure TFormPrincipal.AbreFormBancoExecute(Sender: TObject);
begin
try
Application.CreateForm(Tformbanco,Formbanco);
Formbanco.Parent := PanelCorpo;
Formbanco.Align := alclient;
Formbanco.Show;
finally
Freeandnil(formbanco);
end;
end;
行为是:Formbanco
快速闪烁,几乎不可见,并继续FormPrincipal
。我无法访问Formbanco
!
我非常感谢你的帮助。
答案 0 :(得分:2)
模态形式不能是孩子。所以使用num = input ("Please enter an amount in euros:")
x = int (num)
print (x)
a = x // 500 # The operations are performed to find how many bills of each heat there is and its residue.
x = x% 500
if not a == 0: # Condition for the value of agreement only in the result of the residue in case none exists.
b = x // 200
x = x% 200
else: b = x // 200
yes no b == 0:
c = x // 100
x = x% 100
else: c = x // 100
if not c == 0:
d = x // 50
x = x% 50
else: d = x // 50
if not d == 0:
e = x // 20
x = x% 20
else: e = x // 20
if it is not e == 0:
f = x / 10
x = x% 10
else: f = x // 10
if not f == 0:
g = x // 5
x = x% 5
else: g = x // 5 # I make several conditions that allow me
if not g == 0: #Evaluate the results of each operation
h = x // 2 # immediately above.
x = x% 2
else: h = x // 2
if not h == 0:
i = x // 1
x = x% 1
else: i = x // 1
print ("There", a, "500 euro banknote (s)")
print ("There", b, "ticket (s) of 200 euros")
print ("There", c, "ticket (s) of 100 euros")
print ("There", d, "50 euro banknote (s)") # printout of results
print ("There", and, "ticket (s) of 20 euros")
print ("There", f, "ticket (s) of 10 euros")
print ("There", g, "ticket (s) of 5 euros")
print ("There", h, "currency (s) of 2 euros")
print ("There", i, "currency (s) of 1 euros")
的第二次尝试更好。那里的错误是破坏形式。请记住,Show
是异步的,因此您在创建表单后立即销毁该表单。不要那样做。为了响应另一个事件,你需要在其他地方销毁它。你会知道应该是什么。
该功能应如下所示:
Show
答案 1 :(得分:-1)
如果您将TForm用作面板,请不要这样做。创建TFrame并将其包含在FormPrincipal中的每个组件上。
如果要将表单的内容包含在另一个表单中(在面板内,tabcontrol中......),只有在第二个表单上放置tpanel(或tlayer)作为顶级父级时才能执行。如果要将其包含在其他表单中,请更改其父属性(如果需要,还可以进行对齐)。在这种情况下,您不必显示第二个表单(但当然是创建它):面板/布局在第一个表单上并显示在其上。