//函数单元。
procedure TFormCYBase.ClearText(AControl:TWinControl);
var
I: Integer;
begin
for I := 0 to AControl.ControlCount - 1 do // Iterate
begin
//需清空处理控件
if AControl.Controls[i] is TCustomEdit then
begin
(AControl.Controls[i] as TCustomEdit).Text:='';
end;
if AControl.Controls[i] is TCustomComboBox then
begin
(AControl.Controls[i] as TCustomComboBox).ClearSelection;
end;
//可以 作为 父亲的控件处理事件。
if AControl.Controls[i] is TCustomControl then
begin
ClearText(AControl.Controls[i] as TCustomControl);
end;
end;
end;
//函数调用
procedure TFormCYBase.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
// ESC 键处理事件。
if (Key = VK_ESCAPE) then
begin
ClearText(self);
end;
end;