Jump to content

about login form


Recommended Posts


my name is Luciano, I´m from Brazil,  and I begining develop using uniGUI.


First of all congratulations by this excelent tool ... this is realy good tool...

that´s a dream... 



I don´t know understand how work callback functions ... 


I need a running sample of callback function to a login form 



tnx a lot guys 




Link to comment
Share on other sites

Hi !! .. 


Please, let me explain imho the 'call back 'concept'. Thank you !


The concept behind 'call back functions' is in fact very simple .. but .. very different compared with the 'classic' way.


Consider this:


TForm.ButtonOnClick(Sender: TObject)




  with TLogginDialog.Create(nil) do


     ShowModal() // Here is the problem !!  








Why is there a problem with ShowModal() ? ..  because you normally expect the 'modal behaviour' .. TLogginDialog instance will 'wait' until the operator close the form (apparently 'waiting' in modal state) then the flow of logic will return .. and ... 'finally' the instance will be destroyed (finally free)


But that will not happen


What actually will happen is .. the instance will be created .. then showed .. and the logic will return inmediatly !! .. so, inmediatly destroying the instance just created (excuting, 'finally free')


That of course, will probably lead to some kind of error .. 


Why this happens ?


Because the TLogginDialog instanciated continues running in another thread ..


The point here, is that the caller Form (TForm) .. cannot know 'when' the called Form (TLogginDialog) will 'stop' (in the actual sample, that will happen when the operator close the form)



But the called Form does know when it ends


Because as any Form, has it's own 'OnClose' event .. (probably this event has a 'flag' TCloseAction=caFree, so after its close, will be free .. check out this !)


So the 'idea' here is to 'invert the logic' .. instead of the caller Form knowing whe the called Form returns (in fact cannot know) the called Form, 'informs' the caller when it stops.




TCallerForm <calls> TCalledForm .. TCalledForm <informs 'something'> TCallerForm


How to do this ?


To put it simply, the caller, call the 'other' form .. passing some 'special parameter .. wich in fact is a pointer to a function .. 


TForm.ButtonOnClick(Sender: TObject)








   if oLoginDialog.LogginOkey then





And .. in the OnClose event of the TLoginDialog ..


TLoginDialog.OnClose(Sender: TObject; var Action: TCloseAction);


   if Assigned(pCallBack) then




(Attention ! .. after the TLoginDialog.OnClose .. the TLogginDialog instance will probably be destroyed !)


And that's it !







  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...