yngvi
asked on
Getting a table to refresh after Executing Winexec
This is the situation :
I have a form with a DBGrid on it. There is a button on the form that calls the WinExec procedure and opens up another application witch uses the same databasetable as the form with the DBGrid.
I need to refresh my DBGrid in the former application when I exit the second application ( If I change the data in the second application.
This is the way I am doing it but obviously this doesn´t work. -->
procedure TGetTableData.SpeedButton3 Click(Send er: TObject);
begin
WinExec(PChar(ExtractFileP Ath(Params tr(0)) +
'Tables.exe'), sw_Show);
Table1.Refresh;
end;
thanks!
I have a form with a DBGrid on it. There is a button on the form that calls the WinExec procedure and opens up another application witch uses the same databasetable as the form with the DBGrid.
I need to refresh my DBGrid in the former application when I exit the second application ( If I change the data in the second application.
This is the way I am doing it but obviously this doesn´t work. -->
procedure TGetTableData.SpeedButton3
begin
WinExec(PChar(ExtractFileP
'Tables.exe'), sw_Show);
Table1.Refresh;
end;
thanks!
oops,
ekim you've right, that cannot operate
meikl
ekim you've right, that cannot operate
meikl
hi yngvi,
redirect the Application.OnActivate event to a event in your form
sample
Project code
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TFo rm1, Form1);
// here redirection
Application.OnActivate := Form1.OnActivate;
Application.Run;
end.
Unit Code
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, DBGrids, Db, DBTables;
type
TForm1 = class(TForm)
Table1: TTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
procedure FormActivate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormActivate(Sender : TObject);
begin
Table1.refresh;
end;
end.
redirect the Application.OnActivate event to a event in your form
sample
Project code
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TFo
// here redirection
Application.OnActivate := Form1.OnActivate;
Application.Run;
end.
Unit Code
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, DBGrids, Db, DBTables;
type
TForm1 = class(TForm)
Table1: TTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
procedure FormActivate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormActivate(Sender
begin
Table1.refresh;
end;
end.
ASKER
First I tried the Timer solution and it work OK. Then I tried the Second OnActive solution and I think that it works best.
I don´t know how to give you the points if you want them.
Thanks both !
Yngvi
Iceland
I don´t know how to give you the points if you want them.
Thanks both !
Yngvi
Iceland
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try following in your former form
procedure TForm1.FormActivate(Sender
begin
Table1.Refresh;
end;
meikl