fix rxcloseformvalidator

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2618 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75 2013-01-11 14:19:14 +00:00
parent 1c4e449b92
commit c4969596c7

View File

@ -56,7 +56,7 @@ type
public
constructor Create(ACollection: TCollection); override;
destructor Destroy; override;
function CheckClose:boolean;
function CheckClose(AForm:TCustomForm):boolean;
function ErrorMessage:string;
procedure SetFocus;
published
@ -228,7 +228,7 @@ begin
inherited Destroy;
end;
function TValidateItem.CheckClose: boolean;
function TValidateItem.CheckClose(AForm: TCustomForm): boolean;
var
P:TObject;
PI1, PI2:PPropInfo;
@ -237,6 +237,10 @@ var
begin
Result:=true;
if not Assigned(FControl) then exit;
if FControl = AForm.ActiveControl then
begin
AForm.SelectNext(FControl, true, true);
end;
//Сначала проверим - вдруги это завязки на работу с БД
PI1:=GetPropInfo(Control, 'DataSource');
PI2:=GetPropInfo(Control, 'DataField');
@ -305,7 +309,7 @@ begin
Result:=false;
for i:=0 to FItems.Count-1 do
begin
if FItems[i].Enabled and (not FItems[i].CheckClose) then
if FItems[i].Enabled and (not FItems[i].CheckClose(Owner as TCustomForm)) then
begin
FItems[i].SetFocus;
Application.MessageBox(PChar(FItems[i].ErrorMessage), PChar(FErrorMsgCaption), MB_OK + MB_ICONERROR);