X
xueyong
Unregistered / Unconfirmed
GUEST, unregistred user!
我是通过控制主控窗体菜单的enabled属性控制用户权限的,
下面的一段代码也通过了编译,
但是通过用户登录窗体登录后主控的菜单却没有随它的enabled属性而变化,
请朋友们帮我看看是什么地方出了问题,谢谢!
unit Unit7;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, Mask, ExtCtrls;
type
Tyonghudenglufrm = class(TForm)
CheckBox1: TCheckBox;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Panel1: TPanel;
MaskEdit1: TMaskEdit;
Label1: TLabel;
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
yonghudenglufrm: Tyonghudenglufrm;
pwdfile:textfile;
pwdstr:string ;
times:integer;
implementation
uses unit1;
{$R *.dfm}
procedure Tyonghudenglufrm.BitBtn2Click(Sender: TObject);
begin
if checkbox1.Checked=true then assignfile(pwdfile,'d:/data/guanliyuan.cfg')
else
assignfile(pwdfile,'d:/data/weihu.cfg');
reset(pwdfile);
readln(pwdfile,pwdstr);
closefile(pwdfile);
times:=times+1;
if Maskedit1.Text=pwdstr then
begin
if checkbox1.Checked =true then
begin
zhukongfrm.MainMenu1.Items[0].Enabled:=true;
zhukongfrm.MainMenu1.Items[1].Enabled:=true;
zhukongfrm.MainMenu1.Items[2].Enabled:=true;
zhukongfrm.MainMenu1.Items[3].Enabled:=true;
zhukongfrm.MainMenu1.Items[4].Enabled:=true;
zhukongfrm.MainMenu1.Items[5][0].Enabled:=false;
zhukongfrm.MainMenu1.Items[5][1].Enabled:=true;
zhukongfrm.MainMenu1.Items[5][2].Enabled:=false;
end
else
begin
zhukongfrm.MainMenu1.Items[0].Enabled:=true;
zhukongfrm.MainMenu1.Items[1].Enabled:=true;
zhukongfrm.MainMenu1.Items[2].Enabled:=true;
zhukongfrm.MainMenu1.Items[3].Enabled:=false;
zhukongfrm.MainMenu1.Items[4].Enabled:=false;
zhukongfrm.MainMenu1.Items[5].Enabled:=false;
end;
close;
end
else
begin
if MessageDlg('密码输入错误。是否退出?',mtConfirmation,[mbYes,mbNo],0)
= mrYes then Close
else if times<3 then Maskedit1.SetFocus
else
begin
MessageDlg('对不起,密码输入严重错误!请退出。',mtInformation,[mbOk],0);
application.Terminate ;
end;
end;
end;
procedure Tyonghudenglufrm.BitBtn1Click(Sender: TObject);
begin
zhukongfrm.MainMenu1.Items[0].Enabled:=true;
zhukongfrm.MainMenu1.Items[1].Enabled:=true;
zhukongfrm.MainMenu1.Items[2].Enabled:=false;
zhukongfrm.MainMenu1.Items[3].Enabled:=false;
zhukongfrm.MainMenu1.Items[4].Enabled:=false;
zhukongfrm.MainMenu1.Items[5][1].Enabled:=false;
zhukongfrm.MainMenu1.Items[5][2].Enabled:=false;
close;
end;
procedure Tyonghudenglufrm.FormShow(Sender: TObject);
begin
Maskedit1.Text:='';
end;
procedure Tyonghudenglufrm.FormActivate(Sender: TObject);
begin
Maskedit1.SetFocus;
end;
end.
下面的一段代码也通过了编译,
但是通过用户登录窗体登录后主控的菜单却没有随它的enabled属性而变化,
请朋友们帮我看看是什么地方出了问题,谢谢!
unit Unit7;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, Mask, ExtCtrls;
type
Tyonghudenglufrm = class(TForm)
CheckBox1: TCheckBox;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Panel1: TPanel;
MaskEdit1: TMaskEdit;
Label1: TLabel;
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
yonghudenglufrm: Tyonghudenglufrm;
pwdfile:textfile;
pwdstr:string ;
times:integer;
implementation
uses unit1;
{$R *.dfm}
procedure Tyonghudenglufrm.BitBtn2Click(Sender: TObject);
begin
if checkbox1.Checked=true then assignfile(pwdfile,'d:/data/guanliyuan.cfg')
else
assignfile(pwdfile,'d:/data/weihu.cfg');
reset(pwdfile);
readln(pwdfile,pwdstr);
closefile(pwdfile);
times:=times+1;
if Maskedit1.Text=pwdstr then
begin
if checkbox1.Checked =true then
begin
zhukongfrm.MainMenu1.Items[0].Enabled:=true;
zhukongfrm.MainMenu1.Items[1].Enabled:=true;
zhukongfrm.MainMenu1.Items[2].Enabled:=true;
zhukongfrm.MainMenu1.Items[3].Enabled:=true;
zhukongfrm.MainMenu1.Items[4].Enabled:=true;
zhukongfrm.MainMenu1.Items[5][0].Enabled:=false;
zhukongfrm.MainMenu1.Items[5][1].Enabled:=true;
zhukongfrm.MainMenu1.Items[5][2].Enabled:=false;
end
else
begin
zhukongfrm.MainMenu1.Items[0].Enabled:=true;
zhukongfrm.MainMenu1.Items[1].Enabled:=true;
zhukongfrm.MainMenu1.Items[2].Enabled:=true;
zhukongfrm.MainMenu1.Items[3].Enabled:=false;
zhukongfrm.MainMenu1.Items[4].Enabled:=false;
zhukongfrm.MainMenu1.Items[5].Enabled:=false;
end;
close;
end
else
begin
if MessageDlg('密码输入错误。是否退出?',mtConfirmation,[mbYes,mbNo],0)
= mrYes then Close
else if times<3 then Maskedit1.SetFocus
else
begin
MessageDlg('对不起,密码输入严重错误!请退出。',mtInformation,[mbOk],0);
application.Terminate ;
end;
end;
end;
procedure Tyonghudenglufrm.BitBtn1Click(Sender: TObject);
begin
zhukongfrm.MainMenu1.Items[0].Enabled:=true;
zhukongfrm.MainMenu1.Items[1].Enabled:=true;
zhukongfrm.MainMenu1.Items[2].Enabled:=false;
zhukongfrm.MainMenu1.Items[3].Enabled:=false;
zhukongfrm.MainMenu1.Items[4].Enabled:=false;
zhukongfrm.MainMenu1.Items[5][1].Enabled:=false;
zhukongfrm.MainMenu1.Items[5][2].Enabled:=false;
close;
end;
procedure Tyonghudenglufrm.FormShow(Sender: TObject);
begin
Maskedit1.Text:='';
end;
procedure Tyonghudenglufrm.FormActivate(Sender: TObject);
begin
Maskedit1.SetFocus;
end;
end.