Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2003-02

Show form no modal!!

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bruno Alejandro

Hi!!

Look, I have a form, in this form when I click new open a no modal form, and this second form, open 3 new no modal form... this is ok, the problem is that when I open the second form, instead to create me 1 instance of each of the 3 forms, create me 2 instances, then I have 6 forms plus the 1 I created before.

the code of the project is:

uses
Interfaces,

  Forms, main, idebehavours, ideextensios, ideprop;
begin
  Application.Initialize;
  Application.CreateForm(TfrmFileMgr, frmFileMgr);
  Application.CreateForm(TfrmEditor, frmEditor);
  Application.CreateForm(Tfrmbehavours, frmBehavours);
  Application.CreateForm(Tfrmextensions, frmExtensions);
  Application.CreateForm(TfrmProperties, frmProperties);
  Application.Run;
end.

when I call the first form TfrmEditor I use:

procedure TfrmFileMgr.NewWindow(Sender: TObject);
var
  IDEEDT : TfrmEditor;
begin
  IDEEDT:=TFrmEditor.Create(Application);
  IDEEDT.Show;
end;

This open me 2 instances, but if I use

procedure TfrmFileMgr.NewWindow(Sender: TObject);
var
  IDEEDT : TfrmEditor;
begin
  If not Assigned(IDEEDT) then
    IDEEDT:=TFrmEditor.Create(Application);
  IDEEDT.Show;
end;

Like I used in other aplications, then it crashes, I don't know why...

Thanks for your time...

Bruno Chavez

Reply by email

Bruno Alejandro
to Bruno Alejandro

Hi!!

I correct the problem tks, I was creating the no modal forms in the TfrmEdit.createform, now, I change it to the TfrmFileMgr.createform...

Then I have the 3 window created and opened, and no matter what number of TfrmEdit I open, only will be 1 of each window...

Tks..
Bruno Chavez

Mattias Gaertner wrote 81 lines
On 24 Feb 2003 17:16:23 -0600 Bruno Alejandro wrote: > Hi!! > > Look, I have a form, in this form when I click new open a no modal form, > and this second form, open 3 new no modal form... this is ok, the > problem is that when I open the second form, instead to create me 1 > instance of each of the 3 forms, create me 2 instances, then I have 6 > forms plus the 1 I created before. > > the code of the project is: > > uses > Interfaces, > Forms, main, idebehavours, ideextensios, ideprop; > > begin > Application.Initialize; > Application.CreateForm(TfrmFileMgr, frmFileMgr); > Application.CreateForm(TfrmEditor, frmEditor); > Application.CreateForm(Tfrmbehavours, frmBehavours); > Application.CreateForm(Tfrmextensions, frmExtensions); > Application.CreateForm(TfrmProperties, frmProperties); > Application.Run; > end. > > when I call the first form TfrmEditor I use: > > procedure TfrmFileMgr.NewWindow(Sender: TObject); > var > IDEEDT : TfrmEditor; > begin > IDEEDT:=TFrmEditor.Create(Application); > IDEEDT.Show; > end; > > This open me 2 instances, but if I use The code looks ok. I hope you do not call NewWindow during TfrmFileMgr construction. Can you send a complete example (zip or tgz)? > procedure TfrmFileMgr.NewWindow(Sender: TObject); > var > IDEEDT : TfrmEditor; > begin > If not Assigned(IDEEDT) then This does not work. You are testing, if an uninitialized local variable contains a value. The result depends on the stack and as such is unpredictable. The above is correct. > IDEEDT:=TFrmEditor.Create(Application); > IDEEDT.Show; > end; > > Like I used in other aplications, then it crashes, I don't know why... > > Thanks for your time... Mattias > > Bruno Chavez > > _________________________________________________________________ > To unsubscribe: mail with > "unsubscribe" as the Subject > archives at http://www.lazarus.freepascal.org/mailarchives _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email

Mattias Gaertner
to Bruno Alejandro: Hi!! Look, I have a form, in this form when I click new open a no modal form, and this…
Show quoted text 35 lines
Hi!! Look, I have a form, in this form when I click new open a no modal form, and this second form, open 3 new no modal form... this is ok, the problem is that when I open the second form, instead to create me 1 instance of each of the 3 forms, create me 2 instances, then I have 6 forms plus the 1 I created before. the code of the project is: uses Interfaces, Forms, main, idebehavours, ideextensios, ideprop; begin Application.Initialize; Application.CreateForm(TfrmFileMgr, frmFileMgr); Application.CreateForm(TfrmEditor, frmEditor); Application.CreateForm(Tfrmbehavours, frmBehavours); Application.CreateForm(Tfrmextensions, frmExtensions); Application.CreateForm(TfrmProperties, frmProperties); Application.Run; end. when I call the first form TfrmEditor I use: procedure TfrmFileMgr.NewWindow(Sender: TObject); var IDEEDT : TfrmEditor; begin IDEEDT:=TFrmEditor.Create(Application); IDEEDT.Show; end; This open me 2 instances, but if I use

The code looks ok. I hope you do not call NewWindow during TfrmFileMgr construction.
Can you send a complete example (zip or tgz)?

Show quoted text 5 lines
procedure TfrmFileMgr.NewWindow(Sender: TObject); var IDEEDT : TfrmEditor; begin If not Assigned(IDEEDT) then

This does not work. You are testing, if an uninitialized local variable contains a value. The result depends on the stack and as such is unpredictable. The above is correct.

Show quoted text 7 lines
IDEEDT:=TFrmEditor.Create(Application); IDEEDT.Show; end; Like I used in other aplications, then it crashes, I don't know why... Thanks for your time...

Mattias

Show quoted text 7 lines
Bruno Chavez _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email