我想关闭标题中包含“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
Application
对象没有Forms
属性。您需要改用 Screen.Forms
属性。