I don't know if the solution that I implemented last night is the best one. I did the following:
//FIsEnabledBySecurity: the user can access the control? this variable is changed via another call, when user login or logout, checking the authorizations of the logged user. //FAllowUnauthorizedShowForm: value of a property that sets if not allowed users can show the form or not. procedure TpSCADASecureForm.SetVisible(Value: boolean); override; begin FIsPSCADAFormVisible:=Value; inherited SetVisible(FIsPSCADAFormVisible and (FIsEnabledBySecurity or FAllowUnauthorizedShowForm)); end; this do the job very well, showing and hiding the form across user login/logout changes, even if I call TsomePSCADAFormInstance = class(TpSCADASecureForm); somePSCADAFormInstance:TsomePSCADAFormInstance; somePSCADAFormInstance.Visible := true; somePSCADAFormInstance.Show; but when I call somePSCADAFormInstance.ShowModal; I got a Exception that says that somePSCADAFormInstance is not enabled (that is true, because I have a access try of a not allowed user), but this exception is not the real cause of the problem, that is access of a not allowed user or a not logged user. My solution at this point is override the ShowModal: //FSecurityCode is a property with a string that describes the permission that you will give or not for each user //GetPascalSCADAControlSecurityManager: class instance that manages the control interaction with users and their permissions, 44 //Each control that supports the interface ISecureControlInterface, should register/unregister with this manager, to be notified about user changes/permission changes. function TpSCADASecureForm.ShowModal: Integer; override; begin if GetPascalSCADAControlSecurityManager.CanAccess(FSecurityCode)=false then raise ESecuritySystemAccessDenied.Create(FSecurityCode); Result:=inherited ShowModal; end; What is your opinion?
-- _______________________________________________ Lazarus mailing list Lazarus@lists.lazarus-ide.org http://lists.lazarus-ide.org/listinfo/lazarus