使用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 ;
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 ;