Solved

Lost Focus after calling another .exe

Posted on 1998-06-20
11
238 Views
Last Modified: 2010-04-04
Hi

I have written an Installation program which calls another program (.exe), but when the other program closes, my program has disappeared behind all the open programs.  I have tried setting the FormStyle to fsStayOnTop, which it does, but all the components on the form for some reason become invisible, and I can't even close the program.

My question is, How do I get my program to come to the front after the called program has finished.
0
Comment
Question by:jdthedj
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 5

Expert Comment

by:ronit051397
ID: 1354612
Is that other program is a Delphi program?
0
 
LVL 3

Author Comment

by:jdthedj
ID: 1354613
Hi Ronit - thanks for the reply.

I've just realised that it is not actually calling the .exe because it is a 16 bit ap - the .exe is for installations to Win95 etc.  It is creating a Program Group via DDE, and when the group has been created that stays open, which I want it to, but the Installation program has disappeared behind Program Manager.

I want it to keep the focus.
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1354614
try
SetForegroundWindow(Handle)
or
SetActiveWindow(Handle)
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1354615
Hi jdthedj,

You can execute the exe, get notified when it's finished and then bring your app to top (focuse).

There are components that ease this task very much (exe calliing) - I can send you one so post your email.

bosism@netvision.net.il
0
 
LVL 3

Author Comment

by:jdthedj
ID: 1354616
Hi again Ronit - I tried both of those, but no joy. I also tried BringWindowToTop.

Hi Matvey -  thanks for replying. I am using D1 and WIN 3.11.  My email address is johnd@caverock.net.nz
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Expert Comment

by:Matvey
ID: 1354617
I'll send you two components. The first one is better but it's meant for win32, though there were previous releases and you should contact the author to ask for them if you need them because I think he has no site of his own. But you can find his email inside.

The seccond component is meant both for D1 and D2, and inclued examples for both versions. But I also find this and you should really check it out:

"If you use 16bits version of this component with Delphi 1.0 and wait for
termination of application , you may find that your application can not
be activated again. This is because of limitation of Windows. You can
edit Delphi's debug DLL to avoid this problem. PASDBK16.DLL is located
at DELPHI\BIN, and:

FIND:               E9 40 01 E9 3D
CHANGE TO:   E9 3C 01 E9 3D
                             ^^

-this is a quote from the readme for the seccond component, so it might be the problem...

So tell me what you find. btw: I have also D1 installed, but it's under win32 so it'll be not much help with testing...
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1354618
FIND:                 E9 40 01 E9 3D
CHANGE TO:   E9 3C 01 E9 3D
                                 ^^
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1354619
0
 
LVL 2

Expert Comment

by:hrizal
ID: 1354620
or ...

Begin
   form1.hide;
   ExecFile('bla .. bla ....');
   form1.show;
end;

or

begin
   WinExec('C:\TEST.EXE',SW_HIDE'); // sometimes not work.
   If Not form1.showing then Form1.Show;
end;
0
 
LVL 3

Accepted Solution

by:
Matvey earned 50 total points
ID: 1354621
Hi, Glad I could help!
0
 
LVL 3

Author Comment

by:jdthedj
ID: 1354622
Hi Hrizal - Thanks for replying - I have tried that too, but without success.

Thanks Matvey for your help
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 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

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now