Delphi简单权限控制

来源:互联网 发布:网络教育统考英语难吗 编辑:程序博客网 时间:2024/05/22 16:07

使用TActionList 控件
将要控制的控件的ACTION指向ACTIONLIST1
设置好每个的TAG
ModuleData.MyPower为数据模块中的变量

procedure TForm1.FormShow(Sender: TObject);
var
  I
:Integer;
  Hstr
:string;
  SStr
:string;
begin
  
for I:= 0 to ActionList1.ActionCount - 1 do
  begin
    TAction(ActionList1
.Actions[i]).Visible := False;
    TAction(ActionList1
.Actions[i]).Enabled := False;
  
end;
  Hstr 
:= ','+ModuleData.MyPower+',';
  
for I:= 0 to ActionList1.ActionCount - 1 do
  begin
    SStr 
:= ','+IntToStr(TAction(ActionList1.Actions[i]).Tag)+',';
    
if StrPos(PAnsiChar(Hstr),PAnsiChar(SStr)) <> nil then
    begin
      TAction(ActionList1
.Actions[i]).Visible := True;
      TAction(ActionList1
.Actions[i]).Enabled := True;
    
end;
  
end;
end;
原创粉丝点击