With my application i execute an internet-link in the default browser.
After the browser is started and the link is passed to it i want to
receive the focus back to my application. I tried much things with the
setfocus but that didn't seem to work.
Any1 knows how to make this work ?
cu,
Patrick
--
---
P. van Zweden
pvzw...@no-spam.caiw.nl
*** It's our policy to always blame the computer
If you know the text in the title of the browser:
var
npHWnd : hWnd;
<snip>
npHWnd := 0;
while npHWnd = 0 do
npHWnd := HWndGet( <partialtitle here>);
while GetForeGroundWindow <> npHWnd do
SetForeGroundWindow( npHWnd );
</snip>
function TForm1.HWndGet( partialTitle: string ): hWnd;
var
hWndTemp, iLenText: hWnd;
cTitletemp: array [0..MAX_PATH-1] of Char;
sTitleTemp: string;
begin
//'find first window and loop through all subsequent windows in the master
window list
hWndTemp := FindWindow(nil, nil);
while hWndTemp <> 0 do
begin
// 'retrieve caption text from current window
iLenText := GetWindowText(hWndTemp, cTitletemp, MAX_PATH);
sTitleTemp := cTitletemp;
// 'clean up the return string, preparing for case insensitive
comparison
sTitleTemp := UpperCase(copy( sTitleTemp, 1, iLenText));
// ShowMessage( sTitleTemp );
// 'use appropriate method to determine if the current window's
caption either
// 'starts with or contans passed string
partialTitle := UpperCase( partialTitle );
if pos( partialTitle, sTitleTemp ) <> 0 then
break;
// 'get next window in master window list and continue
hWndTemp := GetWindow(hWndTemp, GW_HWNDNEXT);
end;
result := hWndTemp;
end;
Nic Roche wrote:
> >receive the focus back to my application.
>
> If you know the text in the title of the browser:
>
> var
>
> npHWnd : hWnd;
>
> <snip>
>
> npHWnd := 0;
>
> while npHWnd = 0 do
>
> npHWnd := HWndGet( <partialtitle here>);
>
> while GetForeGroundWindow <> npHWnd do
>
> SetForeGroundWindow( npHWnd );
>
> </snip>
>
--
Intersting one that.
I did a similar thing, whilst calling the Desktop Display Properties
control panel.
All I did was to set the formstyle to fsStayOnTop. This however, may not
be what you want, as the
form will stay on top of your browser whilst the link is being passed to
it.
All the best
Neil J.McLeish
Patrick wrote:
> Hi all,
>
> With my application i execute an internet-link in the default browser.
> After the browser is started and the link is passed to it i want to
> receive the focus back to my application. I tried much things with the
> setfocus but that didn't seem to work.
> Any1 knows how to make this work ?
>
> cu,
>
> Patrick
>
"Neil J. McLeish" wrote:
>
> Hi Patrick.
>
> Intersting one that.
>
> I did a similar thing, whilst calling the Desktop Display Properties
> control panel.
> All I did was to set the formstyle to fsStayOnTop. This however, may not
> be what you want, as the
> form will stay on top of your browser whilst the link is being passed to
> it.
> All the best
>
> Neil J.McLeish
>
Marco Roberto
Patrick <pvzw...@no-spam.caiw.nl> wrote in article
<3635E458...@no-spam.caiw.nl>...
"Marco Roberto Gonçalves Junior" wrote:
>
> Try Application.BringToFront after shellexecute command.
>
> Best Regards,
>
> Marco Roberto