Have you tried passing *SW_SHOWMINNOACTIVE instead of SW_MINIMIZED ?*

Caveat:  The show flag parameter is merely passed to the application being
executed.  What it chooses to do with that flag is it's own affair, but if
you're lucky, it will respect your wishes.  If not, then you will have to
engage in a focus window arms race/lotto as already suggested.  But Route
#1 would be to try the officially mandated mechanisms.

Good luck.  :)


On 24 July 2014 19:46, russell <[email protected]> wrote:

> Tyr this after spawning the other program.
>
>
>
> SetForegroundWindow(forms.application.mainWindow.handle)
>
>
>
> To give the main window of your program focus.
>
> Perhaps modifications of this will take you to the window of the calling
> program where you want the focus?
>
>
>
> Russell
>
>
>
> *From:* [email protected] [mailto:
> [email protected]] *On Behalf Of *John Bird
> *Sent:* Thursday, 24 July 2014 4:43 p.m.
> *To:* NZ Borland Developers Group - Delphi List
> *Subject:* [DUG] Shellexecute question
>
>
>
> I have a program (Program A) that fires up another (program B)  via
> ShellExecute, if its not already running.  However even though Program B is
> started minimised, focus shifts away from Program A, which is a minor
> nuisance.
>
>
>
> Is there any way to stop this within Delphi?  Or will I have to do
> something like delve into the Windows API?
>
>
>
> if ShellExecute(Application.Mainform.Handle, 'open', Pchar(aProgName),
> PChar(aparaml), PChar(aDir), SW_SHOWMINIMIZED) <= 32 then
>
>   ShowMessage('Start Minimised error:')
>
>
>
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: [email protected]
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to [email protected] with
> Subject: unsubscribe
>
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: [email protected]
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to [email protected] with 
Subject: unsubscribe

Reply via email to