Wilton Ergon Posted April 12, 2015 Posted April 12, 2015 ShowModal continues running the application. obtaining the return when the form is completed function PegaData(padrao: TDatetime; texto: string; ValidaAno: Boolean): Tdatetime; begin Result := 0; if padrao > 0 then frmPegaData.edDate.date := padrao; frmPegaData.lbldata.Caption := texto; frmPegaData.ValidaAno := ValidaAno; if frmPegaData.ShowModal =mrOk then BEGIN if frmPegaData.edDate.date > 1 then Result := frmPegaData.edDate.date; END; End; in line if frmPegaData.ShowModal =mrOk then compile erro - Incompatible types. function PegaData(padrao: TDatetime; texto: string; ValidaAno: Boolean): Tdatetime; begin Result := 0; if padrao > 0 then frmPegaData.edDate.date := padrao; frmPegaData.lbldata.Caption := texto; frmPegaData.ValidaAno := ValidaAno; frmPegaData.ShowModal; if frmpegaData.IsOk then //IsOK var type boolean; Result := frmPegaData.edDate.date; End; after showmodal, line if frmpegadata.isOk its run... Quote
zilav Posted April 13, 2015 Posted April 13, 2015 ShowModal doesn't block execution in UniGUI, use callbacks to execute your code after the form is closed. Check demo projects provided with UniGUI. Quote
Wilton Ergon Posted April 13, 2015 Author Posted April 13, 2015 I have a generic search function, which have a form, one edit a grid attached to a datasource the function takes as parameter the sql command, and the return field. the function in turn returns the return value of this field passed as parameter use this function in dozens of points of my application every time it is necessary to search for data in another table and return some value (lookup), instead of using the traditional lockupcombobox which are very limited. in Delphi use the ShowModal, I await the form be completed and get the return and step into the function returns in unigui, as I will proceed to send this return to the function of origin eg and a prototype of this function, of course has many other treatments ... function findtable (sqlcommand, fieldkey: string): string; begin formfind.sql: = sqlcommand; formfind.shomodal; ????????? result: = formfind.qryFind.fieldbyname (fieldkey) .asstring; end; the form that calls the function to get the return value. eg by clicking a button. qryCustomerID.asstring: = findtable ('select name, adress, id from customer', 'id'); Quote
Administrators Farshad Mohajeri Posted April 13, 2015 Administrators Posted April 13, 2015 You must use callbacks to get result from a Modal Form. Quote
docjones Posted April 16, 2015 Posted April 16, 2015 see this http://forums.unigui.com/index.php?/topic/5184-free-form-creation-problem/ Quote
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.