关闭特定于标题的表单 - Delphi

问题描述 投票:0回答:1

我想关闭标题中包含“ClientID”字符串的所有表单。

procedure CloseFormsWithClientID(const ClientID: string);
var
  I: Integer;
  Form: TForm;
begin
  // check if client ID is not empty
  if ClientID <> '' then
  begin
    for I := Application.Forms.Count - 1 downto 0 do
    begin
      Form := Application.Forms[I];
      // check if form contains ClientID
      if Pos(ClientID, Form.Caption) > 0 then
      begin
        // close forms
        Form.Close;
      end;
    end;
  end;
end;

Application.Forms 是未声明的 idretifiers

forms delphi delphi-12-athens
1个回答
0
投票

Application
对象没有
Forms
属性。您需要改用
Screen.Forms
属性。

© www.soinside.com 2019 - 2024. All rights reserved.