
18.10.2012, 10:22
|
 |
Профессионал
|
|
Регистрация: 06.08.2012
Адрес: Кривой Рог
Сообщения: 1,791
Версия Delphi: Delphi 7, XE2
Репутация: 4415
|
|
Вот немного упростил:
Код:
function CheckRed(Src: TComponent; CheckResult: Boolean): Boolean;
procedure Chk(Component: TComponent);
var
IsValid: Boolean;
begin
if Component is TLabel then
begin
IsValid := TLabel(Component).Font.Color <> clRed;
end else
if Component is TStaticText then
begin
IsValid := TStaticText(Component).Font.Color <> clRed;
end else
if Component is TRadioButton then
begin
IsValid := TRadioButton(Component).Font.Color <> clRed;
end else
if Component is TSpeedButton then
begin
IsValid := TSpeedButton(Component).Font.Color <> clRed;
end else
if Component is TDBLookupComboboxEh then
begin
if TDBLookupComboboxEh(Component).EmptyDataInfo.Font.Color = clRed
then IsValid := not VarIsNull(TDBLookupComboboxEh(Component).KeyValue)
else Exit;
end else
if Component is TDBEditEh then
begin
if TDBEditEh(Component).EmptyDataInfo.Font.Color = clRed
then IsValid := TDBEditEh(Component).Text <> ''
else Exit;
end else
if Component is TDBNumberEditEh then
begin
if TDBNumberEditEh(Component).EmptyDataInfo.Font.Color = clRed
then IsValid := TDBNumberEditEh(Component).Text <> ''
else Exit;
end else
begin
Exit;
end;
Result := Result and IsValid;
if not IsValid then
begin //создаём TBaloonHint
_HintCreate(TControl(Src.Components[x]), 'Заполните все поля отмеченые красным', 'Заголовок');
end;
end;
var
x: Integer;
begin
Result := CheckResult;
for x := 0 to Src.ComponentCount - 1 do
begin
Result := Result and CheckRed(Src.Components[x], Result);
Chk(Src.Components[x]);
end;
end;
|