Jump to content

ShowModal form


jocemora75

Recommended Posts

Hello, I work with Delphi and I am new to UniGui, I ask for your help to know the best way to carry out this implementation. I have 2 forms, FormA and FormB. All 2 are created at the same time. FormA calls a function that is located in FormB, and with the value it returns it does another process:

FormA Code: 

procedure TFrameDiagnosticos.UniBitBtn1Click(Sender: TObject);
var
 idDx : Integer;
begin
  idDx := frmbuscadorgenerico1.buscadorgenerico1('CIE9_DETRIPS', 'ID_CIE9', 'COD_CIE9', 'DES_CIE9');
  DmDiagnosticos.abrir_diagnostico(0, idDx);
  UniEdit1.Text := DmDiagnosticos.q_DxPpal.FieldByName('Cod_Cie9').AsString;
end;

FormB Code:

function Tfrmbuscadorgenerico1.buscadorgenerico1(const tabla, id, codigo, descripcion: string): integer;
begin
 UniDBGrid1.Columns[0].FieldName := codigo;
 UniDBGrid1.Columns[1].FieldName := descripcion;

 UniQuery1.Close;
 UniQuery1.SQL.Clear;
 UniQuery1.SQL.Add(Format('Select %s, %s, %s From %s Where %s||%s ',
                   [id,
                    codigo,
                    descripcion,
                    tabla,
                    codigo,
                    descripcion]));
 UniQuery1.SQL.Add('');
 frmbuscadorgenerico1.ShowModalN;
 if UniQuery1.IsEmpty then
  result := -1
 else
  Result := UniQuery1.Fields[0].AsInteger;
 end;

 

If I use this same code in Delphi without Unigui, when I call the function of form2, form2 is displayed, and when it is closed it returns a value. This same code in UniGui works differently, it's called the function but the program goes on and the variable I need never has a valid value. Thanks a lot.

Link to comment
Share on other sites

Hello Jocemora,

In web development, you have to think differently :

1. You have to separate your business logic (code) from your design (forms).

Instead of using functions located on forms, create an unit ( UniDataModule), where you will put all your common code. (Better use class objects inside this unit).

2. For showModal, see :

https://www.unigui.com/doc/online_help/synch-and-asynch-operations.htm

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

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