I have a similar case to yours, I've solved it in the following way
On some forms that are inherited from the same ancestor I have many data
aware components. In the ancestor I have written a virtual method that sets
the ReadOnly property of data aware components to true or false according to
a parameter. In your case this parameter may be the access right of the
user.
As far as I remember in your first post, I think you were avoiding such
a solution... but it works fine with me
Hope this helps
Vahan
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] Behalf
Of jniaj
Sent: Friday, August 05, 2005 2:59 PM
To: [email protected]
Subject: [delphi-en] Re: Standard DataSet Actions
That didn“t work.
Here is the code that validades user permissions:
procedure TfrmMain.Perm(Sender: TObject);
var
S : string;
I: integer;
begin
dmData.tblUser.FindKey([dmData.LoggedUser]);
for I := 0 to ComponentCount-1 do
begin
if Components[I] is TAction then
begin
with Components[I] as TAction do
begin
S := Caption;
if Pos('&', S) > 0 then
Delete(S, Pos('&', S), 1);
if dmData.tblPerm.Locate('Permission',S,[]) then
Enabled := True
else
begin
DisableIfNoHandler := True;
Enabled := False;
end;
end; { with }
end; { if }
Next;
end; { for }
end;
All works fine, except for the DataSet standard actions, that are
automatically enabled as soon as the user enters a form with database
aware components.
--- In [email protected], David Smith <[EMAIL PROTECTED]> wrote:
> from Delphi Help:
>
> property DisableIfNoHandler: Boolean;
>
> Description
> ...
> DisableIfNoHandler specifies whether the Enabled
> property of client components should be set to False
> if no handler can be found for the action.
>
> When the user triggers one of the action's clients,
> the application makes a series of attempts to
> determine how the action should respond. This includes
> checking a number of event handlers, and, if it fails
> to find an event handler, locating a target control
> and checking for a predefined response that applies to
> that target control. When DisableIfNoHandler is True,
> if the application completes this sequence without
> finding any way for the action to respond to the user
> input, The action's Enabled property is set to False.
>
> In addition, for some predefined actions,
> DisableIfNoHandler causes the action to disable itself
> if an event handler is required for the action to
> perform a meaningful task. For example, if you do not
> supply an OnAccept event handler to TFileOpen, then if
> DisableIfNoHandler is True, the action disables itself
> because there is no way for the application to respond
> when the user selects a file name in the dialog.
>
> --- jniaj <[EMAIL PROTECTED]> wrote:
>
> > I am developing a user control that disables the
> > main form actions
> > according to the user permissions.
> > All the database activity is done with the Standard
> > Dataset Actions
> > (TDataSetEdit, TDataSetDelete, etc).
> > The problems arises when the user enters a form full
> > of TDB...
> > controls: the actions are automatically enabled,wich
> > is a normal
> > characteristic of the TDataSet actions.
> > How can I solve this, without having to modify all
> > the database aware
> > forms in all my apps?
> >
> >
> >
>
>
>
>
> ____________________________________________________
> Start your day with Yahoo! - make it your home page
> http://www.yahoo.com/r/hs
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
----------------------------------------------------------------------------
----
YAHOO! GROUPS LINKS
a.. Visit your group "delphi-en" on the web.
b.. To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
----------------------------------------------------------------------------
----
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
<font face=arial size=-1><a
href="http://us.ard.yahoo.com/SIG=12hcdmhhv/M=362335.6886445.7839731.1510227/D=groups/S=1705115362:TM/Y=YAHOO/EXP=1123254679/A=2894361/R=0/SIG=13jmebhbo/*http://www.networkforgood.org/topics/education/digitaldivide/?source=YAHOO&cmpgn=GRP&RTP=http://groups.yahoo.com/">In
low income neighborhoods, 84% do not own computers. At Network for Good, help
bridge the Digital Divide!</a>.</font>
--------------------------------------------------------------------~->
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/delphi-en/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/