Цитата:
Сообщение от Freeman
А можно вообще весь этот быдлокод выкинуть и чтение/установку свойств расписать через RTTI: GetObjProp и GetOrdProp/SetOrdProp. Получится строчек 10, не больше. Навскидку пример не нашел, а писать лень.
|
глаза разуй выше код написан, и даже в в варианте с GetObjProp мне нужно не для всех типов объектов эту проверку делать, так что мой вариант для моих целей мне больше подходит, а ты бы сперва свой вариант привёл прежде чем чужой код опускать
финальный вариант кстати выглядит так:
Код:
function CheckRed(Src:TComponent;CheckResult:Boolean):Boolean;
var x:Integer;
procedure Chk(Component:TComponent);
var IsValid:Boolean;
begin
IsValid:=True;
if Component is TLabel then IsValid:=TLabel(Component).Font.Color<>clRed else
if Component is TStaticText then IsValid:=TStaticText(Component).Font.Color<>clRed else
if Component is TRadioButton then IsValid:=TRadioButton(Component).Font.Color<>clRed else
if Component is TSpeedButton then
begin
if TControl(Component).Parent.ClassName<>'TPopupCalculatorEh' then 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)
end else
if Component is TDBEditEh then
begin
if TDBEditEh(Component).EmptyDataInfo.Font.Color=clRed then IsValid:=TDBEditEh(Component).Text<>'';
end else
if Component is TDBNumberEditEh then if TDBNumberEditEh(Component).EmptyDataInfo.Font.Color=clRed then IsValid:=TDBNumberEditEh(Component).Text<>'';
Result:=Result and IsValid;
if not IsValid then _HintCreate(TControl(Component),'Заполните все поля отмеченые красным','заголовок');
end;
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;