Topic: logout button

Hi guys
In my project, I have not used the role based access control .
I have two users and I created a login form  with a combobox for username and a textbox for password
is there any way that I create a logout button (frmMain button 10) to change between the users?
thanks

Post's attachments

Attachment icon logout1.zip 337.22 kb, 88 downloads since 2023-05-08 

Re: logout button

identity wrote:

Hi guys
In my project, I have not used the role based access control .
I have two users and I created a login form  with a combobox for username and a textbox for password
is there any way that I create a logout button (frmMain button 10) to change between the users?
thanks

1......

procedure frmMain_OnClose (Sender: TObject; Action: string);
begin
  frmLogin.Show;
end;

procedure frmMain_Button10_OnClick (Sender: TObject; var Cancel: boolean);
begin
  frmMain.Close;
end;

   
2...

procedure frmMain_OnClose (Sender: TObject; Action: string);
begin
  if (frmMain.TagString = 'ResetUser') then frmLogin.Show else frmLogin.Close;
  frmMain.TagString := '';
end;

procedure frmMain_Button10_OnClick (Sender: TObject; var Cancel: boolean);
begin
  frmMain.TagString := 'ResetUser';
  frmMain.Close;
end;

Re: logout button

thanks pavlenko.vladimir.v
I used the second option.
it works fine but there is only one big problem.
I need all the buttons for the user to be disabled and for the admin all the buttons should be enabled.
with your script when I log in with Admin, all the the buttons are enabled correctly but when I Log in with user and re-login to the admin, then all the buttons are disabled.

Post's attachments

Attachment icon logout2.zip 337.65 kb, 77 downloads since 2023-05-09 

Re: logout button

identity wrote:

thanks pavlenko.vladimir.v
I used the second option.
it works fine but there is only one big problem.
I need all the buttons for the user to be disabled and for the admin all the buttons should be enabled.
with your script when I log in with Admin, all the the buttons are enabled correctly but when I Log in with user and re-login to the admin, then all the buttons are disabled.

На сколько я помню, мой пример не предусматривал смену пользователя.
 
Вам нужно просто вернуь Enabled в True при закрытии формы

procedure frmMain_OnClose (Sender: TObject; Action: string);
begin
  if (frmMain.TagString = 'ResetUser') then frmLogin.Show else frmLogin.Close;
  frmMain.TagString := '';

  frmMain.Button1.Enabled := True;
  frmMain.Button2.Enabled := True;
  frmMain.Button3.Enabled := True;
  frmMain.Button4.Enabled := True;
end;
Post's attachments

Attachment icon logout2.rar 7 kb, 98 downloads since 2023-05-09