Ian Branch 127 Posted September 24, 2019 Hi Guys, in particular JVCL Gurus, I am playing with the JvLoginDialog. It runs immediately the App is started and seemingly before the application's Form is created. I want to use it to verify the log in details of a user from a database table. Unfortunately the database bits are on the Form, engine, session, connection, table, and as a result they are not seen when the component's OnCheckUser event fires. :-( Naturally I can't find any documented Help for the component. Can anybody advise how to achieve what I am trying to do or can't I? Regards & TIA, Ian 1 Share this post Link to post
rvk 33 Posted September 24, 2019 4 hours ago, Ian Branch said: It runs immediately the App is started and seemingly before the application's Form is created. That depends on where you put the TJvLoginDialog. If you have a DataModule, ideally the TJvLoginDialog goes on the TDataModule and you'll execute it in the DataModuleCreate() after connecting to the TDatabase. Set Active to false at designtime so you can do this yourself in the DataModuleCreate(). Login.Active := true; if not Login.Execute then begin // inform the user and exit Application.Terminate; end; In the OnCheckUser you can check the database if the user has entered valid credentials. If you have the TDatabase component on a TForm and you initialize it there, then you'll need to put the TJvLoginDialog there too (in FormCreate() and after the initialization of the TDatabase-component). Share this post Link to post
Ian Branch 127 Posted September 24, 2019 Ahh Excellent. Tks RVK. Is there a mechanism to use the AttemptNumber is it just a place holder? Regards & Tks, Ian Share this post Link to post
rvk 33 Posted September 24, 2019 Looking at the source, each time you press the OK button a private variable FAttempt is increased. When it goes over the AttemptNumber a Cancel is automatically triggered. So the Login will fail. procedure TJvLoginForm.OkBtnClick(Sender: TObject); begin Inc(FAttempt); if Assigned(FOnOkClick) then FOnOkClick(Self) else ModalResult := mrOk; if (ModalResult <> mrOk) and (FAttempt >= AttemptNumber) then ModalResult := mrCancel; end; Share this post Link to post
Ian Branch 127 Posted September 24, 2019 Hi RVK, Ahh. I see. And I have determined that setting 'AllowLogin' in the CheckUser procedure to false is what to manage the count. I think I have all that I need now. Tks. Regards, Ian Share this post Link to post