//函數單元。
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;