lucksjb Posted March 4, 2013 Share Posted March 4, 2013 Hi 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 Luciano Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted March 4, 2013 Administrators Share Posted March 4, 2013 See one of the related demos available under demos\ folder. Quote Link to comment Share on other sites More sharing options...
lucksjb Posted March 4, 2013 Author Share Posted March 4, 2013 what´s demo that show how create a callback form ? tnx again Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted March 4, 2013 Administrators Share Posted March 4, 2013 Form Callback Form Anonymous Callback Quote Link to comment Share on other sites More sharing options...
alasoft Posted March 4, 2013 Share Posted March 4, 2013 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) begin . with TLogginDialog.Create(nil) do try ShowModal() // Here is the problem !! finally Free; end; . end; 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. So: 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) begin oLoginDialog:=LoginDialog.Create(LoginDialogCallBack); oLoginDialog.ShowModal(); end; TForm.LoginDialogCallBack; begin if oLoginDialog.LogginOkey then . . end; And .. in the OnClose event of the TLoginDialog .. TLoginDialog.OnClose(Sender: TObject; var Action: TCloseAction); begin if Assigned(pCallBack) then pCallBack; end; (Attention ! .. after the TLoginDialog.OnClose .. the TLogginDialog instance will probably be destroyed !) And that's it ! Regards Rober 1 Quote Link to comment Share on other sites More sharing options...
lucksjb Posted March 4, 2013 Author Share Posted March 4, 2013 tnx Rober.. I would try do it do u have any sample ´cause I don´t have the folow samples : Form Callback Form Anonymous Callback tnx advanced... Luciano my facebook http://www.facebook.com/luciano.silva.71216141 Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted March 4, 2013 Administrators Share Posted March 4, 2013 You have those samples under demos folder. Quote Link to comment Share on other sites More sharing options...
alasoft Posted March 4, 2013 Share Posted March 4, 2013 Please follow the samples provides by Farshad ... I'll will try to guive my own anyway. Rober Quote Link to comment Share on other sites More sharing options...
lucksjb Posted March 4, 2013 Author Share Posted March 4, 2013 tnx for all I know do ... and I´m sending my sample tnx anymore.... SampleFormModal.rar Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.