Welcome! Log In Create A New Profile

Advanced

WD12 - bring another app to front

Posted by Arie 
Arie
WD12 - bring another app to front
January 13, 2009 04:45PM
Hi,
using ExeRunning() / ExeRun() I can start an application, which is not yet running.
Now I want to bring a already running application to the front!
I'm able to get the PID of an instance by using ExeListProcess(), but can't succeed in bring it to front.
I tried several API-calls, but still no luck.

Does anyone have an example of doing this?

Arie
Fabrice Harari
Re: WD12 - bring another app to front
January 13, 2009 07:55PM
Hi Arie,

look SysSetFocus in the help

Best regards

Arie
Re: WD12 - bring another app to front
January 13, 2009 10:28PM
Fabrice,
I tried that already.
SysSetFocus needs a windowhandle. But I do not know the handle of a window of an application which is not mine.
SysWinHandle() could do this, but then I need to know the EXACT window title. Which is unknown (depends on the state of this application at that very moment - i.e. ResWinHandle = SysWinHandle("Microsoft Word - Sales.DOC")).

So basicly my problem is to found out the window-handle of another process. I tried to enumerate all processes (calling EnumProcesses() in isapi.dll) and find the windowhandle via its PID. But no luck so far.

Arie


Arie
Re: WD12 - bring another app to front - SOLVED
January 15, 2009 10:10PM
I solved this. I made a small DLL in Delphi to do this:
1. enumerating all processes and scan for the required executable.
2. Then enumerating all windows, which belong to this process. And get the one with no parent-handle.

Finally, back in Windev, I had to CallDLL32("User32.dll","SetForegroundWindow",nHandle)

I will post a small demo-project under solutions, these days.

Arie
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: