"OK" 按钮 (TButton) 未在 Tform (Pascal) 上显示

"OK" Button (TButton) not showing on Tform (Pascal)

我有一个工作正常的表格 (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;

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

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

点击按钮时会运行此程序,仅供测试。当我可以在表单上显示“确定”按钮时,我将创建更多代码。

procedure ChkQtyOKClick;

begin
    frmChkQty.close;
end;

谢谢。

在 Delphi 中,当我删除

时按钮变得可见
  frmChkQtybtnOK.anchors := [akright];

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

P.S。在 TForm.Create

之后移动 try