在unit里有一个权限函数:
function popedom(url: string): Boolean;
var
ADOQuery1:TADOQuery;
begin
ADOQuery1:=TADOQuery.Create(Application.Owner);
ADOQuery1.Connection:=FormLogin.ADOConnection1;
with ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from ...');
Open;
if RecordCount>0 then
begin
result:=true;
end
else
begin
showmessage('对不起,你没有使用此功能的权限');
result:=false;
end;
end;
end;在创建时判断:
if popedom('FormXsdAdd')=true then
begin
FormXsdAdd := TFormXsdAdd.Create(Self);
FormXsdAdd.ShowModal;
end;
这样固然效果不错,但如果很多地方都要创建这个窗口,那要判断的地方就多了,以后维护也不方便。被创建的窗口里写:
procedure TFormXsdAdd.FormCreate(Sender: TObject);
begin
if not popedom('FormXsdAdd') then
PostMessage(Handle, WM_CLOSE, 0, 0);
end;结果是窗口虽然没显示,但窗口闪了一下,所以效果不是很好。有没更好的办法让窗口不显示?
function popedom(url: string): Boolean;
var
ADOQuery1:TADOQuery;
begin
ADOQuery1:=TADOQuery.Create(Application.Owner);
ADOQuery1.Connection:=FormLogin.ADOConnection1;
with ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from ...');
Open;
if RecordCount>0 then
begin
result:=true;
end
else
begin
showmessage('对不起,你没有使用此功能的权限');
result:=false;
end;
end;
end;在创建时判断:
if popedom('FormXsdAdd')=true then
begin
FormXsdAdd := TFormXsdAdd.Create(Self);
FormXsdAdd.ShowModal;
end;
这样固然效果不错,但如果很多地方都要创建这个窗口,那要判断的地方就多了,以后维护也不方便。被创建的窗口里写:
procedure TFormXsdAdd.FormCreate(Sender: TObject);
begin
if not popedom('FormXsdAdd') then
PostMessage(Handle, WM_CLOSE, 0, 0);
end;结果是窗口虽然没显示,但窗口闪了一下,所以效果不是很好。有没更好的办法让窗口不显示?
form1.showmodal
无权限时enabled=false,点都不能点,此过程在进入界面时就一次处理完成.