<div dir="ltr"><div>We've had a lot of challenges forcing the focus of an application. If the above doesn't work, after Program B is launched, you can try setting Program A's FromStyle to fsStayOnTop, then immediately set it back to normal again.<br>
<br></div>Robo<br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 24, 2014 at 9:46 AM, russell <span dir="ltr"><<a href="mailto:russell@belding.co.nz" target="_blank">russell@belding.co.nz</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="white" link="blue" vlink="purple" lang="EN-NZ"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Tyr this after spawning the other program.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">SetForegroundWindow(forms.application.mainWindow.handle)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">To give the main window of your program focus.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Perhaps modifications of this will take you to the window of the calling program where you want the focus?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Russell<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext" lang="EN-US">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext" lang="EN-US"> <a href="mailto:delphi-bounces@listserver.123.net.nz" target="_blank">delphi-bounces@listserver.123.net.nz</a> [mailto:<a href="mailto:delphi-bounces@listserver.123.net.nz" target="_blank">delphi-bounces@listserver.123.net.nz</a>] <b>On Behalf Of </b>John Bird<br>
<b>Sent:</b> Thursday, 24 July 2014 4:43 p.m.<br><b>To:</b> NZ Borland Developers Group - Delphi List<br><b>Subject:</b> [DUG] Shellexecute question<u></u><u></u></span></p></div></div><div><div><p class="MsoNormal">
<u></u> <u></u></p><div><div><div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">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.</span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif""> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">Is there any way to stop this within Delphi? Or will I have to do something like delve into the Windows API?</span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif""> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif"">if ShellExecute(Application.Mainform.Handle, 'open', Pchar(aProgName), PChar(aparaml), PChar(aDir), SW_SHOWMINIMIZED) <= 32 then<u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif""> ShowMessage('Start Minimised error:')<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif""> <u></u><u></u></span></p>
</div></div></div></div></div></div></div><br>_______________________________________________<br>
NZ Borland Developers Group - Delphi mailing list<br>
Post: <a href="mailto:delphi@listserver.123.net.nz" target="_blank">delphi@listserver.123.net.nz</a><br>
Admin: <a href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a><br>
Unsubscribe: send an email to <a href="mailto:delphi-request@listserver.123.net.nz" target="_blank">delphi-request@listserver.123.net.nz</a> with Subject: unsubscribe<br></blockquote></div><br></div></div>