Solved

Getting a table to refresh after Executing Winexec

Posted on 1998-10-14
5
149 Views
Last Modified: 2010-05-18
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.SpeedButton3Click(Sender: TObject);
begin
  WinExec(PChar(ExtractFilePAth(Paramstr(0)) +      
  'Tables.exe'), sw_Show);
  Table1.Refresh;
end;


thanks!
0
Comment
Question by:yngvi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1342820
hi,

try following in your former form

procedure TForm1.FormActivate(Sender: TObject);
begin
  Table1.Refresh;
end;

meikl
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1342822
oops,

ekim you've right, that cannot operate

meikl
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1342823
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(TForm1, 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.

0
 

Author Comment

by:yngvi
ID: 1342824
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
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 110 total points
ID: 1342825
hi yngvi,

give the points the best solution.
if you mean that my solution is better, than give me the points
otherwise reject my answer

meikl
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question