FoxPro Programming
Controlling Internet Explorer
Gravatar is a globally recognized avatar based on your email address. Controlling Internet Explorer
  David Middleton
  All
  Jul 1, 2015 @ 03:48am
This is not a WestWind question, but maybe someone could help:

In a VFP app, I am calling up IE and navigating it to a relevant website connected to the app.

So, starting IE with:

oBrowser = Createobject("InternetExplorer.Application")
oBrowser.Visible = .T.

After I run this, the browser is sometimes behind the VFP window. How can I bring the IE window to the front so the user will see it?

Thanks,

David.


David

Gravatar is a globally recognized avatar based on your email address. Re: Controlling Internet Explorer
  Rick Strahl
  David Middleton
  Jul 1, 2015 @ 07:35am
Yup I've run into this myself in Help Builder. It's messy and there's no easy solution to this - you basically would have to use the Windows API functions to find the window by name then force it to the top of the Window stack. There are functions in wwAPI that can help with most of that but it takes quite a bit of trial and error.

In Help Builder where I use a Web Browser for live preview I had those same problems, so I decided to ditch Internet Explorer application object in an external browser and instead use a Web Browser Control in a top level window. This allows much more control over the window and also works around some of the problem of using the IE object in your app (like IE doesn't release and you can only bring up so many instances before it won't work anymore).

+++ Rick ---



This is not a WestWind question, but maybe someone could help:

In a VFP app, I am calling up IE and navigating it to a relevant website connected to the app.

So, starting IE with:

oBrowser = Createobject("InternetExplorer.Application")
oBrowser.Visible = .T.

After I run this, the browser is sometimes behind the VFP window. How can I bring the IE window to the front so the user will see it?

Thanks,

David.




Rick Strahl
West Wind Technologies

Making waves on the Web
from Maui

Gravatar is a globally recognized avatar based on your email address. Re: Controlling Internet Explorer
  David Middleton
  Rick Strahl
  Jul 1, 2015 @ 10:09am
Hi Rick,

Thanks for that info. I think I will demo to my client as it is, and if they like the general principle, I will then investigate a Web browser control in a top-level window.

David.


Yup I've run into this myself in Help Builder. It's messy and there's no easy solution to this - you basically would have to use the Windows API functions to find the window by name then force it to the top of the Window stack. There are functions in wwAPI that can help with most of that but it takes quite a bit of trial and error.

In Help Builder where I use a Web Browser for live preview I had those same problems, so I decided to ditch Internet Explorer application object in an external browser and instead use a Web Browser Control in a top level window. This allows much more control over the window and also works around some of the problem of using the IE object in your app (like IE doesn't release and you can only bring up so many instances before it won't work anymore).

+++ Rick ---



This is not a WestWind question, but maybe someone could help:

In a VFP app, I am calling up IE and navigating it to a relevant website connected to the app.

So, starting IE with:

oBrowser = Createobject("InternetExplorer.Application")
oBrowser.Visible = .T.

After I run this, the browser is sometimes behind the VFP window. How can I bring the IE window to the front so the user will see it?

Thanks,

David.





David

Gravatar is a globally recognized avatar based on your email address. Re: Controlling Internet Explorer
  Rick Strahl
  David Middleton
  Jul 1, 2015 @ 03:49pm
So I looked at my old code you can do somehting like this:


o = CREATEOBJECT("InternetExplorer.Application")
o.Visible = .t.
? o.Parent

DO wwAPI
Winapi_sleep(2000)
?o.Parent.HWND
ActivateWindow(o.Parent.HWND)

ActivateWindow looks like this:

************************************************************************
* wwAPI :: WinApi_ActivateWindow
****************************************
*** Function: Activates the
*** Assume:
*** Pass: lcTitle - Exact Window Title or Window Handle Number
*** Return:
************************************************************************

FUNCTION ActivateWindow(lcTitle,lnParentHandle)

IF VARTYPE(lcTitle) = "C"
IF EMPTY(lnParentHandle)
lnParentHandle = 0
ENDIF

DECLARE INTEGER FindWindow ;
IN WIN32API ;
STRING cNull,STRING cWinName

lnHandle = FindWindow(lnParentHandle,lcTitle)
ELSE
lnHandle = lcTitle
ENDIF

DECLARE INTEGER SetForegroundWindow ;
IN WIN32API INTEGER

SetForegroundWindow(lnHandle)

RETURN
ENDFUNC

Seems to work - you just have to make sure that the window is indeed visible.

+++ Rick ---


Hi Rick,

Thanks for that info. I think I will demo to my client as it is, and if they like the general principle, I will then investigate a Web browser control in a top-level window.

David.


Yup I've run into this myself in Help Builder. It's messy and there's no easy solution to this - you basically would have to use the Windows API functions to find the window by name then force it to the top of the Window stack. There are functions in wwAPI that can help with most of that but it takes quite a bit of trial and error.

In Help Builder where I use a Web Browser for live preview I had those same problems, so I decided to ditch Internet Explorer application object in an external browser and instead use a Web Browser Control in a top level window. This allows much more control over the window and also works around some of the problem of using the IE object in your app (like IE doesn't release and you can only bring up so many instances before it won't work anymore).

+++ Rick ---



This is not a WestWind question, but maybe someone could help:

In a VFP app, I am calling up IE and navigating it to a relevant website connected to the app.

So, starting IE with:

oBrowser = Createobject("InternetExplorer.Application")
oBrowser.Visible = .T.

After I run this, the browser is sometimes behind the VFP window. How can I bring the IE window to the front so the user will see it?

Thanks,

David.







Rick Strahl
West Wind Technologies

Making waves on the Web
from Maui

Gravatar is a globally recognized avatar based on your email address. Re: Controlling Internet Explorer
  David Middleton
  Rick Strahl
  Jul 3, 2015 @ 12:55am
Thanks Rick. Really helpful.

I have wwApi with your Client Tools, so am calling ActivateWindows there - and it works.

David.


So I looked at my old code you can do somehting like this:


o = CREATEOBJECT("InternetExplorer.Application")
o.Visible = .t.
? o.Parent

DO wwAPI
Winapi_sleep(2000)
?o.Parent.HWND
ActivateWindow(o.Parent.HWND)

ActivateWindow looks like this:

************************************************************************
* wwAPI :: WinApi_ActivateWindow
****************************************
*** Function: Activates the
*** Assume:
*** Pass: lcTitle - Exact Window Title or Window Handle Number
*** Return:
************************************************************************

FUNCTION ActivateWindow(lcTitle,lnParentHandle)

IF VARTYPE(lcTitle) = "C"
IF EMPTY(lnParentHandle)
lnParentHandle = 0
ENDIF

DECLARE INTEGER FindWindow ;
IN WIN32API ;
STRING cNull,STRING cWinName

lnHandle = FindWindow(lnParentHandle,lcTitle)
ELSE
lnHandle = lcTitle
ENDIF

DECLARE INTEGER SetForegroundWindow ;
IN WIN32API INTEGER

SetForegroundWindow(lnHandle)

RETURN
ENDFUNC

Seems to work - you just have to make sure that the window is indeed visible.

+++ Rick ---


Hi Rick,

Thanks for that info. I think I will demo to my client as it is, and if they like the general principle, I will then investigate a Web browser control in a top-level window.

David.


Yup I've run into this myself in Help Builder. It's messy and there's no easy solution to this - you basically would have to use the Windows API functions to find the window by name then force it to the top of the Window stack. There are functions in wwAPI that can help with most of that but it takes quite a bit of trial and error.

In Help Builder where I use a Web Browser for live preview I had those same problems, so I decided to ditch Internet Explorer application object in an external browser and instead use a Web Browser Control in a top level window. This allows much more control over the window and also works around some of the problem of using the IE object in your app (like IE doesn't release and you can only bring up so many instances before it won't work anymore).

+++ Rick ---



This is not a WestWind question, but maybe someone could help:

In a VFP app, I am calling up IE and navigating it to a relevant website connected to the app.

So, starting IE with:

oBrowser = Createobject("InternetExplorer.Application")
oBrowser.Visible = .T.

After I run this, the browser is sometimes behind the VFP window. How can I bring the IE window to the front so the user will see it?

Thanks,

David.








David

© 1996-2024