How do I get the MenuIten.Click event to run in an if loop? Delphi

0

I'm setting up the login part of my system, but I'm having a big problem. My cancel button on the login screen it needs to receive two features. The first is that being clicked before the main system screen is opened the application is all finished. If the main screen is already open it is to do the second functionality that would be canceling the user exchange at run time! That is, the cancellation of the logout, the user exchange canceled. However for the logic that I am using it works, it has to be passed by an if, so the logout click is an ItemMenu of a MainMenu. If I use it like this

if FrmPrincipal.Logout1.Click = True then

It accuses error of incompatible type If I use this another way

if FrmPrincipal.Logout1.OnClick

It's the error and does not spin. That's what I wanted to know ... how do I get an ItemMenu to run in an if loop.

    
asked by anonymous 10.04.2017 / 14:44

1 answer

1

If I were you, I'd control with a private variable feeding into the main's onCreate, so it would open the Login and the Login onCreate would feed the variable with False, the main onShow check whether it's to login or not, looking at the variable. In the following way:

onCreate Primary:

bLogin := False;
fmLogin := TfmLogin.Create(Self); 
try
  fmLogin.ShowModal;
  bLogin := fmLogin.OKLogin;
finally
   FreeAndNil(fmLogin);
end;

onCreate Login:

bOKLogin := False

onShow Primary:

if bLogin then
begin
  ...
end
else
begin
  Application.Terminate;
end;

But starting from your logic, you can call the OnClick event of the Logout, not having to check whether you clicked or not.

   FrmPrincipal.Logout1.OnClick(Sender)

You can also control with a Checked in MenuItem, in MenuItem it has a property with AutoCheck, checking this property it will control the check in the MenuItem, so you can check if it is checked or not when it clicks MenuItem. p>

 if testecheck.Checked then
     ShowMessage('teste');
    
10.04.2017 / 15:35