Jump to content

showmodal continue application...


Wilton Ergon

Recommended Posts

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...

 

 

 

Link to comment
Share on other sites

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');
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...