Board index » delphi » Cannot update data in a MDI child

Cannot update data in a MDI child

Hi everybody,

I have the following problem:

I have two MDI child windows

{ I call this MDI child from Twindow1}
Twindow2.Create(self);
{ I do some editing of data in this window }
{ If the user closes Twindow2, i want to update for example a Label in
Twindow1}

Label1.caption := Datamodule1.AdressApollo.Getstring(NAME);

The problem is this that the field "NAME" that has been changed in
Twindows2 is not being updated in Label1
I have tested what is happening, when i call the Twindow2 it passes
immediately Label1. So when the user closes Twindow2 it will never pass
Label1 anymore.

I hope somebody can help me.

Greetings,

Robert Copier

 

Re:Cannot update data in a MDI child


Quote
Robert Copier wrote in message <35604F87.7E379...@monicom.nl>...
>Hi everybody,

>I have the following problem:

>I have two MDI child windows

>{ I call this MDI child from Twindow1}
>Twindow2.Create(self);
>{ I do some editing of data in this window }
>{ If the user closes Twindow2, i want to update for example a Label in
>Twindow1}

>Label1.caption := Datamodule1.AdressApollo.Getstring(NAME);

>The problem is this that the field "NAME" that has been changed in
>Twindows2 is not being updated in Label1
>I have tested what is happening, when i call the Twindow2 it passes
>immediately Label1. So when the user closes Twindow2 it will never pass
>Label1 anymore.

>I hope somebody can help me.

>Greetings,

>Robert Copier

program Project1;

uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1},
  Unit2 in 'Unit2.pas' {Form2},
  Unit3 in 'Unit3.pas' {Form3};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TForm3, Form3);
  Application.Run;
end.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
uses unit2;
{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
  begin
  Edit1.Text:= 'is this what you are looking for';
  end;
end.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
uses unit2;
{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
  begin
  Edit1.Text:= 'is this what you are looking for';
  end;
end.

unit Unit3;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, ToolWin, ComCtrls;

type
  TForm3 = class(TForm)
    ToolBar1: TToolBar;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form3: TForm3;

implementation
uses unit1,unit2;
{$R *.DFM}

procedure TForm3.Button2Click(Sender: TObject);
begin
 Application.CreateForm(TForm2, Form2);
 Form2.Edit1.text:=Form1.Edit1.Text;
 Form1.Free;
 Form2.Show;
end;

procedure TForm3.Button1Click(Sender: TObject);
begin
 Application.CreateForm(TForm1, Form1);
 Form1.Show;
end;

end.

Re:Cannot update data in a MDI child


Hi,

This does not work because:

procedure TForm3.Button2Click(Sender: TObject);
begin
 { When you call the following MDI child, the program already ended this
procedure.}
 Application.CreateForm(TForm2, Form2); { In this form the data changes }

{ On this point a need the data the has been changed in the closed window
before, of course }
{ the data is in a database }

 Form2.Edit1.text:=Form1.Edit1.Text; {This will workt because the edit1.text is
already know}
 Form1.Free;
 Form2.Show;
end;

Greetings,

Robert Copier

Bruce Eckerd schreef:

Quote
> Robert Copier wrote in message <35604F87.7E379...@monicom.nl>...
> >Hi everybody,

> >I have the following problem:

> >I have two MDI child windows

> >{ I call this MDI child from Twindow1}
> >Twindow2.Create(self);
> >{ I do some editing of data in this window }
> >{ If the user closes Twindow2, i want to update for example a Label in
> >Twindow1}

> >Label1.caption := Datamodule1.AdressApollo.Getstring(NAME);

> >The problem is this that the field "NAME" that has been changed in
> >Twindows2 is not being updated in Label1
> >I have tested what is happening, when i call the Twindow2 it passes
> >immediately Label1. So when the user closes Twindow2 it will never pass
> >Label1 anymore.

> >I hope somebody can help me.

> >Greetings,

> >Robert Copier

> program Project1;

> uses
>   Forms,
>   Unit1 in 'Unit1.pas' {Form1},
>   Unit2 in 'Unit2.pas' {Form2},
>   Unit3 in 'Unit3.pas' {Form3};

> {$R *.RES}

> begin
>   Application.Initialize;
>   Application.CreateForm(TForm3, Form3);
>   Application.Run;
> end.

> unit Unit1;

> interface

> uses
>   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
>   StdCtrls;

> type
>   TForm1 = class(TForm)
>     Button1: TButton;
>     Memo1: TMemo;
>     Edit1: TEdit;
>     procedure Button1Click(Sender: TObject);
>   private
>     { Private declarations }
>   public
>     { Public declarations }
>   end;

> var
>   Form1: TForm1;

> implementation
> uses unit2;
> {$R *.DFM}

> procedure TForm1.Button1Click(Sender: TObject);
>   begin
>   Edit1.Text:= 'is this what you are looking for';
>   end;
> end.

> unit Unit1;

> interface

> uses
>   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
>   StdCtrls;

> type
>   TForm1 = class(TForm)
>     Button1: TButton;
>     Memo1: TMemo;
>     Edit1: TEdit;
>     procedure Button1Click(Sender: TObject);
>   private
>     { Private declarations }
>   public
>     { Public declarations }
>   end;

> var
>   Form1: TForm1;

> implementation
> uses unit2;
> {$R *.DFM}

> procedure TForm1.Button1Click(Sender: TObject);
>   begin
>   Edit1.Text:= 'is this what you are looking for';
>   end;
> end.

> unit Unit3;

> interface

> uses
>   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
>   StdCtrls, Buttons, ToolWin, ComCtrls;

> type
>   TForm3 = class(TForm)
>     ToolBar1: TToolBar;
>     BitBtn1: TBitBtn;
>     BitBtn2: TBitBtn;
>     procedure Button2Click(Sender: TObject);
>     procedure Button1Click(Sender: TObject);
>   private
>     { Private declarations }
>   public
>     { Public declarations }
>   end;

> var
>   Form3: TForm3;

> implementation
> uses unit1,unit2;
> {$R *.DFM}

> procedure TForm3.Button2Click(Sender: TObject);
> begin
>  Application.CreateForm(TForm2, Form2);
>  Form2.Edit1.text:=Form1.Edit1.Text;
>  Form1.Free;
>  Form2.Show;
> end;

> procedure TForm3.Button1Click(Sender: TObject);
> begin
>  Application.CreateForm(TForm1, Form1);
>  Form1.Show;
> end;

> end.

Other Threads