Jump to content

Problem creating form in runtime


Guest

Recommended Posts

When I create a form in runtime, from showmodal form created in

runtime, with this code:

 

procedure TExpPerCalendario.BModificarClick(Sender: TObject);

 

var ExpPerSolicitude : TExpPerSolicitude;

 

begin

 

  if QuerySol.IsEmpty then Exit;

 

  ExpPerSolicitude := TExpPerSolicitude.Create(uniApplication);

 

  ExpPerSolicitude.Modo := 'M';

 

  ExpPerSolicitude.Part := Part;

 

  ExpPerSolicitude.CodExpte :=

QueryExp.FieldByName('EXPDIA_CODIGO').AsInteger;

 

  ExpPerSolicitude.Codigo :=

QuerySol.FieldByName('EXPPERPER_CODIGO').AsInteger;

 

  ExpPerSolicitude.ShowModal;

 

  if ExpPerSolicitude.Modo = 'R' then begin

 

    QuerySol.Refresh;

 

    QuerySol.Locate('EXPPERPER_CODIGO',ExpPerSolicitude.Codigo,

[])

 

  end;

 

  ExpPerSolicitude.Free;

 

end;

 

 

 

Obtain this message:

 

Object O166 not found in session list. It could be timed out,

refresh page and try again.

 

 

 

I can not solve this problem. Can help me?

 

 

 

Link to comment
Share on other sites

Message from: "LDiaz"

 

El 08/02/2011 11:46, LDiaz escribió:

> When I create a form in runtime, from showmodal form created in

> runtime, with this code:

> *procedure TExpPerCalendario.BModificarClick(Sender: TObject);

> var ExpPerSolicitude : TExpPerSolicitude;

> begin

> if QuerySol.IsEmpty then Exit;

> ExpPerSolicitude := TExpPerSolicitude.Create(uniApplication);

> ExpPerSolicitude.Modo := 'M';

> ExpPerSolicitude.Part := Part;

> ExpPerSolicitude.CodExpte :=

> QueryExp.FieldByName('EXPDIA_CODIGO').AsInteger;

> ExpPerSolicitude.Codigo :=

> QuerySol.FieldByName('EXPPERPER_CODIGO').AsInteger;

> ExpPerSolicitude.ShowModal;

> if ExpPerSolicitude.Modo = 'R' then begin

> QuerySol.Refresh;

> QuerySol.Locate('EXPPERPER_CODIGO',ExpPerSolicitude.Codigo, [])

> end;

> ExpPerSolicitude.Free;

> end;

>

> *Obtain this message:

> *Object O166 not found in session list. It could be timed out, refresh

> page and try again.*

>

> I can not solve this problem. Can help me?

>

I forget said, this work fine in VCL mode and fails an isapi mode.

 

.

 

Link to comment
Share on other sites

Message from: "Farshad Mohajeri"

 

"LDiaz" wrote in message =

news:9Hm4113xLHA.2164@anaxagvs227...

When I create a form in runtime, from showmodal form created in =

runtime, with this code:

procedure TExpPerCalendario.BModificarClick(Sender: TObject);

var ExpPerSolicitude : TExpPerSolicitude;

begin

if QuerySol.IsEmpty then Exit;

ExpPerSolicitude :=3D TExpPerSolicitude.Create(uniApplication);

ExpPerSolicitude.Modo :=3D 'M';

ExpPerSolicitude.Part :=3D Part;

ExpPerSolicitude.CodExpte :=3D =

QueryExp.FieldByName('EXPDIA_CODIGO').AsInteger;

ExpPerSolicitude.Codigo :=3D =

QuerySol.FieldByName('EXPPERPER_CODIGO').AsInteger;

ExpPerSolicitude.ShowModal; // in WebMode ShowModal is not blocking

 

// you should do below in Form's OnClose event

if ExpPerSolicitude.Modo =3D 'R' then begin

QuerySol.Refresh;

QuerySol.Locate('EXPPERPER_CODIGO',ExpPerSolicitude.Codigo, [])

end;

 

ExpPerSolicitude.Free; // there is no need to call free, by default =

Forms are freed when you close them

end;

 

Obtain this message:

Object O166 not found in session list. It could be timed out, refresh =

page and try again.

 

I can not solve this problem. Can help me?

 

 

 

Link to comment
Share on other sites

Message from: "LDiaz"

 

http-equiv="Content-Type">

El 08/02/2011 12:11, Farshad Mohajeri escribió:

  ExpPerSolicitude.ShowModal;  // in

WebMode ShowModal is not blocking

 

// you should do below in Form's

OnClose event

I don´t understand.

 

I do this:

 

 

Link to comment
Share on other sites

Message from: "LDiaz"

 

El 08/02/2011 12:37, LDiaz escribió:

> El 08/02/2011 12:11, Farshad Mohajeri escribió:

>> * ExpPerSolicitude.ShowModal; // in WebMode ShowModal is not blocking

>> *

>> *// you should do below in Form's OnClose event*

> I don´t understand.

> I do this:

> -- In Main form I create in runtime a form : ExpPerCalendario and show

> it with Showmodal.

> -- This form have a button for crete and open a third form

> ExpPerSolicitude in showmodal mode (see above code).

> -- When I click in this button error sucess and Obtain this message:

> *Object O166 not found in session list. It could be timed out, refresh

> page and try again.*

Well. I understand now.

If the first call is Show (not Showmodal) work fine and the second call

block the other windows.

Not is posible do showmodal calls from the showmodal window.

It´s right?

.

 

Link to comment
Share on other sites

Message from: "Farshad Mohajeri"

 

"LDiaz" wrote in message

news:Rsillh4xLHA.2164@anaxagvs227...

> El 08/02/2011 12:37, LDiaz escribió:

>> El 08/02/2011 12:11, Farshad Mohajeri escribió:

>>> * ExpPerSolicitude.ShowModal; // in WebMode ShowModal is not blocking

>>> *

>>> *// you should do below in Form's OnClose event*

>> I don´t understand.

>> I do this:

>> -- In Main form I create in runtime a form : ExpPerCalendario and show it

>> with Showmodal.

>> -- This form have a button for crete and open a third form

>> ExpPerSolicitude in showmodal mode (see above code).

>> -- When I click in this button error sucess and Obtain this message:

>> *Object O166 not found in session list. It could be timed out, refresh

>> page and try again.*

> Well. I understand now.

> If the first call is Show (not Showmodal) work fine and the second call

> block the other windows.

> Not is posible do showmodal calls from the showmodal window.

> It´s right?

 

In Web Mode showModal does not block the thread. In VCL mode it does. The

difference is due complexity of implementing ShowModal behaviour in WebMode.

 

You should not write any code after a call to ShowModal and instead handle

it in OnClose event.

 

 

.

 

Link to comment
Share on other sites

Message from: "LDiaz"

 

El 08/02/2011 13:07, Farshad Mohajeri escribió:

> "LDiaz" wrote in message

> news:Rsillh4xLHA.2164@anaxagvs227...

>> El 08/02/2011 12:37, LDiaz escribió:

>>> El 08/02/2011 12:11, Farshad Mohajeri escribió:

>>>> * ExpPerSolicitude.ShowModal; // in WebMode ShowModal is not blocking

>>>> *

>>>> *// you should do below in Form's OnClose event*

>>> I don´t understand.

>>> I do this:

>>> -- In Main form I create in runtime a form : ExpPerCalendario and show it

>>> with Showmodal.

>>> -- This form have a button for crete and open a third form

>>> ExpPerSolicitude in showmodal mode (see above code).

>>> -- When I click in this button error sucess and Obtain this message:

>>> *Object O166 not found in session list. It could be timed out, refresh

>>> page and try again.*

>> Well. I understand now.

>> If the first call is Show (not Showmodal) work fine and the second call

>> block the other windows.

>> Not is posible do showmodal calls from the showmodal window.

>> It´s right?

> In Web Mode showModal does not block the thread. In VCL mode it does. The

> difference is due complexity of implementing ShowModal behaviour in WebMode.

>

> You should not write any code after a call to ShowModal and instead handle

> it in OnClose event.

Ok. Thank you for your patience.

 

.

 

Link to comment
Share on other sites

 

 

You

should not write any code after a call to ShowModal and instead

handle

 

 

it in OnClose event

How I do this?. I try in onClose event this code:

 

TExpPerCalendario(Self.Owner).QuerySol.Refresh;

 

But get a exception.

 

Forgive

class="hps">my

ignorance

 

Link to comment
Share on other sites

Message from: "zilav"

 

I=E2=80=99ve made a small demo for you, but perhaps Farshad can advise a =

better way.

 

"LDiaz" =

=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B8=D0=BB(=D0=B0) =D0=B2 =

=D0=BD=D0=BE=D0=B2=D0=BE=D1=81=D1=82=D1=8F=D1=85 =

=D1=81=D0=BB=D0=B5=D0=B4=D1=83=D1=8E=D1=89=D0=B5=D0=B5:E2WrmcFyLHA.2160@a=

naxagvs227...

 

 

You should not write any code after a call to ShowModal and instead =

handle=20

it in OnClose event

How I do this?. I try in onClose event this code:

TExpPerCalendario(Self.Owner).QuerySol.Refresh;

But get a exception.

Forgive my ignorance

 

 

Link to comment
Share on other sites

Message from: "Farshad Mohajeri"

 

"LDiaz" wrote in message =

news:E2WrmcFyLHA.2160@anaxagvs227...

 

 

You should not write any code after a call to ShowModal and instead =

handle=20

it in OnClose event

How I do this?. I try in onClose event this code:

TExpPerCalendario(Self.Owner).QuerySol.Refresh;

But get a exception.

Forgive my ignorance

 

Apparently "Self" is a TUniForm and its Owner is UniAppliaction. You =

can't cast UniAppliaction to other types.

 

Where does your QuerySol component reside? On another Form or on a =

DataModule?

 

Link to comment
Share on other sites

Message from: "LDiaz"

 

El 09/02/2011 14:28, Farshad Mohajeri escribió:

>

> "LDiaz" >

> wrote in message news:E2WrmcFyLHA.2160@anaxagvs227...

>

>> You should not write any code after a call to ShowModal and

>> instead handle

>> it in OnClose event

> How I do this?. I try in onClose event this code:

> *TExpPerCalendario(Self.Owner).QuerySol.Refresh;*

> But get a exception.

> Forgive my ignorance

>

> Apparently "Self" is a TUniForm and its Owner is UniAppliaction. You

> can't cast UniAppliaction to other types.

> Where does your QuerySol component reside? On another Form or on a

> DataModule?

In another form: (TExpPerCalendario). This form calls to

TExpPerSolicitude(when close this form return to de

first:TExpPerCalendario and refresh QuerySol ).

.

 

Link to comment
Share on other sites

Message from: "Farshad Mohajeri"

 

"LDiaz" wrote in message

news:3xZzLAGyLHA.2160@anaxagvs227...

> El 09/02/2011 14:28, Farshad Mohajeri escribió:

>>

>> "LDiaz" >

>> wrote in message news:E2WrmcFyLHA.2160@anaxagvs227...

>>

>>> You should not write any code after a call to ShowModal and

>>> instead handle

>>> it in OnClose event

>> How I do this?. I try in onClose event this code:

>> *TExpPerCalendario(Self.Owner).QuerySol.Refresh;*

>> But get a exception.

>> Forgive my ignorance

>>

>> Apparently "Self" is a TUniForm and its Owner is UniAppliaction. You

>> can't cast UniAppliaction to other types.

>> Where does your QuerySol component reside? On another Form or on a

>> DataModule?

> In another form: (TExpPerCalendario). This form calls to

> TExpPerSolicitude(when close this form return to de

> first:TExpPerCalendario and refresh QuerySol ).

 

Good. The simply call it this way:

 

UniFormX.QuerySol.Refresh;

 

"UniFormX" is the form where your query component resides.

 

 

.

 

Link to comment
Share on other sites

zilav escribió:

zilav: I’ve made a small demo for you,

but perhaps Farshad can advise a better way.

This Example work fine. But

class="short_text" lang="en">in a large application

class="hps">is a

bit

title="Haz clic para obtener traducciones alternativas"

class="hps">complicated

.

 

 

 

: UniFormX.QuerySol.Refresh; 

This

title="Haz clic para obtener traducciones alternativas"

class="hps">I don't know

how to do. See

sample:

 

height="58">

Main

 

uses

 

  UniGUIVars, MainModule, uniControls, Unit1;

 

 

 

function MainForm: TMainForm;

 

begin

 

  Result :=

TMainForm(UniMainModule.GetFormInstance(TMainForm));

 

end;

 

 

 

procedure TMainForm.UniButton1Click(Sender: TObject);

 

var F1 : TUniForm1;

 

begin

 

  F1 := TUniForm1.Create(UniApplication);

 

  F1.Show;

 

end;

 

 

In F1 have a UniEditex

class="short_text" lang="en">

 

height="58">

Unit1

 

uses

 

  uniControls, Unit2;

 

 

 

procedure TUniForm1.UniButton1Click(Sender: TObject);

 

var F2 : TUniForm2;

 

begin

 

  F2 := TUniForm2.Create(UniApplication);

 

  F2.ShowModal;

 

end;

 

 

height="58">

Unit2

 

uses

 

  uniControls, Unit1;

 

 

 

procedure TUniForm2.UniButton1Click(Sender: TObject);

 

begin

 

  Close;

 

end;

 

 

 

procedure TUniForm2.UniFormClose(Sender: TObject; var

Action: TCloseAction);

 

var F1 : TUniForm1;

 

begin

 

  F1.UniEdit1.text := 'Go back from Form2';

color="#990000">   // The program send a exception

 

end;

 

 

Can you help me?

 

 

 

Link to comment
Share on other sites

Message from: "Farshad Mohajeri"

 

"LDiaz"

Unit2

=20

uses

uniControls, Unit1;

 

procedure TUniForm2.UniButton1Click(Sender: TObject);

begin

Close;

end;

 

procedure TUniForm2.UniFormClose(Sender: TObject; var Action: =

TCloseAction);

var F1 : TUniForm1;

begin

F1.UniEdit1.text :=3D 'Go back from Form2'; // The program =

send a exception

end;

=20

 

 

You shouldn't declare a new local Var.

 

Just call it this way.

 

UniForm1.UniEdit1.text :=3D 'Go back from Form2';

 

Link to comment
Share on other sites

Message from: "Farshad Mohajeri"

 

"LDiaz" wrote in message =

news:E$Ly%23fRyLHA.2720@anaxagvs227...

El 10/02/2011 11:04, Farshad Mohajeri escribi=C3=B3:=20

 

"LDiaz"

Unit2

=20

uses

uniControls, Unit1;

 

procedure TUniForm2.UniButton1Click(Sender: TObject);

begin

Close;

end;

 

procedure TUniForm2.UniFormClose(Sender: TObject; var =

Action: TCloseAction);

var F1 : TUniForm1;

begin

F1.UniEdit1.text :=3D 'Go back from Form2'; // The =

program send a exception

end;

=20

 

 

You shouldn't declare a new local Var.

 

Just call it this way.

 

UniForm1.UniEdit1.text :=3D 'Go back from Form2';

This not compile. See image.

Attach project files.

 

 

OK.

 

I see now.

 

You've created your Form in Unit1 as standard Form not "Application =

Form".

 

In uniGUI Wizard create an Application Form and replace it with Unit1.

 

Link to comment
Share on other sites

 

 

I see now.

 

You've created your Form in Unit1

as standard Form not "Application Form".

 

In uniGUI Wizard create an

Application Form and replace it with Unit1.

 

 

Crete Uniform1 and Uniform2 as ApplicationForms and no give me

error, but Form2 not send text to Form1.Edittext1.

 

See video:

 

http://www.youtube.com/watch?v=ouV5RgcTyzg

 

 

 

Link to comment
Share on other sites

Message from: "Farshad Mohajeri"

 

"Luis Diaz" wrote in message =

news:nQLm2HUyLHA.2164@anaxagvs227...

 

 

I see now.

 

You've created your Form in Unit1 as standard Form not "Application =

Form".

 

In uniGUI Wizard create an Application Form and replace it with =

Unit1.

 

Crete Uniform1 and Uniform2 as ApplicationForms and no give me error, =

but Form2 not send text to Form1.Edittext1.

See video:

http://www.youtube.com/watch?v=3DouV5RgcTyzg

 

 

When using Application Forms you should not create forms yourself just =

refer to them by calling their instance such as UniForm1, UniForm2, =

MainForm and etc.

Framework automatically creates Forms for you when it is needed.

 

Link to comment
Share on other sites

Message from: "Farshad Mohajeri"

 

See attached

"Luis Diaz" wrote in message =

news:nQLm2HUyLHA.2164@anaxagvs227...

 

 

I see now.

 

You've created your Form in Unit1 as standard Form not "Application =

Form".

 

In uniGUI Wizard create an Application Form and replace it with =

Unit1.

 

Crete Uniform1 and Uniform2 as ApplicationForms and no give me error, =

but Form2 not send text to Form1.Edittext1.

See video:

http://www.youtube.com/watch?v=3DouV5RgcTyzg

 

 

 

Link to comment
Share on other sites

El 10/02/2011 17:53, Farshad Mohajeri escribió:

 

 

 

I see now.

 

You've created your Form in

Unit1 as standard Form not "Application Form".

 

In uniGUI Wizard create an

Application Form and replace it with Unit1.

 

Crete Uniform1 and Uniform2 as ApplicationForms and no give me

error, but Form2 not send text to Form1.Edittext1.

 

See video:

 

href="http://www.youtube.com/watch?v=ouV5RgcTyzg">http://www.youtube.com/watch?v=ouV5RgcTyzg

 

 

 

When using Application Forms you

should not create forms yourself just refer to them by

calling their instance such as UniForm1, UniForm2, MainForm

and etc.

Framework automatically creates

Forms for you when it is needed.

Excuse

class="hps">my

ignorance

title="Haz clic para obtener traducciones alternativas"

class="hps">but

I do not understand.

 

I need crete Form1 in runtime. From Form1 I create in runtime

Form2 and showmodal it . Form1 wait in backgroud a response of

Form2. When I close Form2 send a string to Form1.Editext1. This

is an example. In a real application I put in Form1 a read-only

Grid when I click in a row  create Form2 and edit field values.

When edit finish I close Form2 and send to Form1 command for

refresh a grid.

 

title="Haz clic para obtener traducciones alternativas"

class="hps">We are

talking about

title="Haz clic para obtener traducciones alternativas"

class="hps">the

same

title="Haz clic para obtener traducciones alternativas">?

In

class="hps">that

case can you do a example

for me with the Project1

class="" lang="en"> I sent

title="Haz clic para obtener traducciones alternativas"

class="hps">this

morning?

Link to comment
Share on other sites

Message from: "Farshad Mohajeri"

 

"Luis Diaz" wrote in message =

news:6LBcYXUyLHA.2160@anaxagvs227...

El 10/02/2011 17:53, Farshad Mohajeri escribi=C3=B3:=20

 

"Luis Diaz" wrote in message =

news:nQLm2HUyLHA.2164@anaxagvs227...

 

 

I see now.

 

You've created your Form in Unit1 as standard Form not =

"Application Form".

 

In uniGUI Wizard create an Application Form and replace it with =

Unit1.

 

Crete Uniform1 and Uniform2 as ApplicationForms and no give me =

error, but Form2 not send text to Form1.Edittext1.

See video:

http://www.youtube.com/watch?v=3DouV5RgcTyzg

 

 

When using Application Forms you should not create forms yourself =

just refer to them by calling their instance such as UniForm1, UniForm2, =

MainForm and etc.

Framework automatically creates Forms for you when it is needed.

Excuse my ignorance but I do not understand.=20

I need crete Form1 in runtime.

 

There is no difference. When you calll UniForm1 for first time it is =

created at runtime automatically.

If you want to create it yourself then create it and keep its instance =

in a Variable for future reference.

 

 

From Form1 I create in runtime Form2 and showmodal it . Form1 wait in =

backgroud a response of Form2. When I close Form2 send a string to =

Form1.Editext1. This is an example. In a real application I put in Form1 =

a read-only Grid when I click in a row create Form2 and edit field =

values. When edit finish I close Form2 and send to Form1 command for =

refresh a grid.

We are talking about the same? In that case can you do a example for =

me with the Project1 I sent this morning?

 

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