“确定”按钮(TButton)未显示在Tform(Pascal)上

时间:2017-09-14 02:37:22

标签: pascal tform

我有一个表格(Tform)可以正常使用。

我添加了另一个显示TEdit和TLabel对象的表单,但不会在表单上显示TButton对象。代码如下。

procedure LoadQtyForm;

begin
    try
    frmChkQty := TForm.Create(nil);
    frmChkQty.Width := 400;
    frmChkQty.Height := 200;
    frmChkQty.Caption := 'Check, Confirm, Change Quantity';
    frmChkQty.Position := poScreenCenter;
    frmChkQty.BorderStyle := bsSingle;
    frmChkQty.Name := 'SecondaryForm';

    { Panel within Form }
    frmChkQtyTopPnl := TPanel.Create(frmChkQty);
    frmChkQtyTopPnl.Parent := frmChkQty;
    frmChkQtyTopPnl.Align := alclient;

    { OK button }
    frmChkQtybtnOK := TButton.Create(frmChkQtyTopPnl);
    //frmChkQtybtnOK := TButton.Create(Self);
    frmChkQtybtnOK.Parent := frmChkQtyTopPnl;
    frmChkQtybtnOK.left := 50; //300
    frmChkQtybtnOK.Top := 50;  //170
    frmChkQtybtnOK.Width := 90;
    frmChkQtybtnOK.Height := 20;
    frmChkQtybtnOK.Caption := '&OK';
    frmChkQtybtnOK.OnClick := 'ChkQtyOKClick';
    //frmChkQtybtnOK.taborder := 98;
    frmChkQtybtnOK.anchors := akright;
    //frmChkQtybtnOK.anchors := akbottom;

    frmChkQtylblfield := TLabel.Create(frmChkQtyTopPnl);
    frmChkQtylblfield.parent := frmChkQtyTopPnl;
    frmChkQtylblfield.left := 100;
    frmChkQtylblfield.top := 40;
    frmChkQtylblfield.font.size := 12;
    frmChkQtylblfield.caption := 'Current Laser Cut Qty is ';

    { To get Qty that was laser cut }
    frmChkQtyedtfield := TEdit.Create(frmChkQtyTopPnl);
    frmChkQtyedtfield.parent := frmChkQtyTopPnl;
    frmChkQtyedtfield.left := 275;
    frmChkQtyedtfield.top := 80;
    frmChkQtyedtfield.Width := 50;
    frmChkQtyedtfield.font.size := 12;
    frmChkQtyedtfield.Text := '1';

    frmChkQtylblfield2 := TLabel.Create(frmChkQtyTopPnl);
    frmChkQtylblfield2.parent := frmChkQtyTopPnl;
    frmChkQtylblfield2.left := 100;
    frmChkQtylblfield2.top := 80;
    frmChkQtylblfield2.font.size := 12;
    frmChkQtylblfield2.caption := 'This Laser Cut Qty is:';

    {
    frmChkQtyedtfield2 := TEdit.Create(frmChkQtyTopPnl);
    frmChkQtyedtfield2.parent := frmChkQtyTopPnl;
    frmChkQtyedtfield2.left := 285;
    frmChkQtyedtfield2.top := 40;
    frmChkQtyedtfield2.Width := 50;
    frmChkQtyedtfield2.Height := 40;
    frmChkQtyedtfield2.font.size := 12;
    frmChkQtyedtfield2.Text := '1';
    }

    frmChkQty.showmodal;
    finally
    frmChkQty.Free
    end;
end;

以下变量已全局声明:

 //Create Variables for Second form to get/check/confirm quantities
 frmChkQty: Tform;
 frmChkQtyTopPnl:       TPanel;
 frmChkQtybtnOK:        Tbutton;
 frmChkQtylblfield:     TLabel;
 frmChkQtylblfield2:    TLabel;
 frmChkQtyedtfield:     TEdit;
 frmChkQtyedtfield2:    TEdit;

谁能告诉我为什么按钮没有出现?

这是使用Pascal编写的名为Ostendo的程序中编写的脚本的一部分。

单击该按钮时,将运行此过程,该过程仅用于测试。当我可以在表单上显示OK按钮时,我将创建更多代码。

procedure ChkQtyOKClick;

begin
    frmChkQty.close;
end;

感谢。

1 个答案:

答案 0 :(得分:1)

删除时,Delphi按钮变为可见

  frmChkQtybtnOK.anchors := [akright];

所以按钮确实可见,但由于在表格显示过程中重新计算,其坐标超出了界限

P.S。在try

之后移动TForm.Create