Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOW to get IE on top of APP

Status
Not open for further replies.

Nifrabar

Programmer
Mar 16, 2003
1,343
NL
Hi!

In my app I have possibility to show an address using google.maps.
Google.maps shows up in IE-window.
Once I click outside that window in my app I do have my app-window fully available.
If I want to use google.maps again (via my app) than that window is not on top of my app window.
In the taskbar I can see the IE-window is there but not simple to handle for my users this way.

Any suggestion on that?

TIA
-Bart
 
Do you mean that if the IE window loses focus, and your app comes to the foreground, that even if your app changes the contents of the IE window - it remains (perhaps minimised) as a background item?

If so, are you asking for a way to 'promote' the IE window to be 'foreground' again?



Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Bart,

I suggest - not tested - to make a button on your screen in the click event you set the focus to your google.maps function / or you make your Vfp.IE window.state = normal instead of minimized

Groet,

Jockey(2)
 
Bart,

Do you mean that you want some way for the application to automatically bring the existing IE window to the front?

If so, try the following code. I wrote it in a hurry, and haven't tried to test it, but it should give you a start:

Code:
* Do these DECLARES once only, near the 
* start of the app
DECLARE INTEGER GetWindow IN Win32API ;
  INTEGER hWnd, INTEGER nType

DECLARE INTEGER GetWindowText IN Win32API ;
  INTEGER hWnd, STRING @cText, INTEGER nType
	
DECLARE INTEGER ShowWindow IN Win32API ;
  INTEGER hWnd, INTEGER CmdShow		
	
LOCAL hNext, cTitle, cText

* Get handle of the app's window
hNext = _SCREEN.hWnd

* Edit this to the title of your IE window
cTilte = "Google Maps IE"

* Iterate through the windows in the stack
DO WHILE hNext<>0 
 cText = REPLICATE(CHR(0),80)
 GetWindowText(hNext,@cText,80)
	
 IF UPPER(cTitle) $ UPPER(cText)
  * This is the IE window
		
  * Bring it to the front
  ShowWindow(hNext,1)  && 1 means show in normal window
  EXIT
 ENDIF
	
 hNext = GetWindow(hNext,2)
ENDDO

You could run this from a button within your app, or when the app gets focus, depending on what you want.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Griff: yes that is what I need.

Jockey(2): AS far as I can see this is just a normal IE window. So I can't control that window from within VFP

Mike: Looks good. Going to give this a try and will inform about result.

KR
-Bart
 
Why not just create a form with IE control and that way you can control from your program. You can minimize, maximize, hide etc when you want
 
rlhme : if you can show me how I can give it a try.
kr
-Bart
 
Why not just create a form with IE control and that way you can control from your program.

Rhlme: Yes, that occurred to me as well. However, there are couple of reasons:

1. It's a lot easier to do a simple ShellExecute() than to do a form with a web browser control.

2. With the way Bart is doing it, his map will appear in the user's preferred browser. With the web browser control, the user is forced to use IE.

3. He doesn't have to worry about providing features such as printing the map, print preview, zooming, saving the web page, full page view, etc. They're all provided by the browser, without any programming on his part.

That said, you're right that doing it in a form has other advantages - including the ability to easily bring it to the front if required.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Hope this gives you some idea

Public ofrmgooglemap


ofrmgooglemap=Newobject("frmgooglemap")
ofrmgooglemap.Show
Return


**************************************************
*-- Form: frmgooglemap (xxxxxxxxxxxxxxxx)
*-- ParentClass: frm (xxxxxxxxxxxxxxxxxxxxxxxxx)
*-- BaseClass: form
*-- Time Stamp: 09/18/09 02:57:09 PM
*
Define Class frmgooglemap As frm


Top = -3
Left = 1
Height = 600
Width = 800
DoCreate = .T.
Caption = "Google Map"
Name = "FRMGOOGLEMAP"


Add Object BrowseR As OleControl With ;
Top = 0, ;
Left = 0, ;
Height = 600, ;
Width = 800, ;
Anchor = 15, ;
Name = "browser"




Procedure Init
Lparameters lnFk_employee, lnFk_client, lcGoogleorMapquest, lnFk_office

** i use a method call to get a cursor for the employee and client called myEmployeeInfo and myClientInfo

If Empty(lcGoogleorMapquest)
lcGoogleorMapquest = ''
Endif


Do Case

Case !Empty(lnFk_employee) And !Empty(lnFk_client) And Empty(lnFk_office) &&&& directions employee to client
&&& get address string for map
lcEmployee_address_string = &&& code to set up address string for employee
lcClient_address_string = &&& method call to set up client address string

*** assume no address for employee
lcAddressEmployee = ''

If !Empty(Alltrim(myEmployeeInfo.add1))
lcAddressEmployee = lcAddressEmployee +Alltrim(myEmployeeInfo.add1)
Endif
If !Empty(Alltrim(myEmployeeInfo.town))
lcAddressEmployee = lcAddressEmployee + '+'+Alltrim(myEmployeeInfo.town)
Endif

If !Empty(Alltrim(myEmployeeInfo.state))
lcAddressEmployee = lcAddressEmployee + '+'+Alltrim(myEmployeeInfo.state)

Endif

If !Empty(Alltrim(myEmployeeInfo.zip))
lcAddressEmployee = lcAddressEmployee + '+'+Alltrim(myEmployeeInfo.zip)
Endif

lcEmployeeName = 'EMPLOYEE: '+Alltrim(myEmployeeInfo.name_full)


lcAddressClient = ''

If !Empty(Alltrim(myClientInfo.add1))
lcAddressClient = lcAddressClient+Alltrim(myClientInfo.add1)
Endif
If !Empty(Alltrim(myClientInfo.town))
lcAddressClient = lcAddressClient+ '+'+Alltrim(myClientInfo.town)
Endif

If !Empty(Alltrim(myClientInfo.state))
lcAddressClient = lcAddressClient+ '+'+Alltrim(myClientInfo.state)

Endif

If !Empty(Alltrim(myClientInfo.zip))
lcAddressClient = lcAddressClient+ '+'+Alltrim(myClientInfo.zip)
Endif


lcClientName = 'CLIENT: '+Alltrim(myClientInfo.name_full)


This.Caption = 'Directions from '+lcEmployeeName+' to '+lcClientName



This.BrowseR.Navigate(' lcAddressEmployee+;
'('+lcEmployeeName+')'+;
'&daddr='+lcAddressClient+;
'('+lcClientName+')')


Case Empty(lnFk_employee) And !Empty(lnFk_client) And Empty(lnFk_office) &&& map client
lcClient_address_string = &&& your code here


lcAddressClient = ''

If !Empty(Alltrim(myClientInfo.add1))
lcAddressClient = lcAddressClient+Alltrim(myClientInfo.add1)
Endif
If !Empty(Alltrim(myClientInfo.town))
lcAddressClient = lcAddressClient+ '+'+Alltrim(myClientInfo.town)
Endif

If !Empty(Alltrim(myClientInfo.state))
lcAddressClient = lcAddressClient+ '+'+Alltrim(myClientInfo.state)

Endif

If !Empty(Alltrim(myClientInfo.zip))
lcAddressClient = lcAddressClient+ '+'+Alltrim(myClientInfo.zip)
Endif


lcClientName = 'CLIENT: '+Alltrim(myClientInfo.name_full)


This.Caption = 'Map for '+lcClientName



This.BrowseR.Navigate(' lcAddressClient+'('+lcClientName+')')


Case !Empty(lnFk_employee) And Empty(lnFk_client) And Empty(lnFk_office) &&& map employee

lcEmployee_address_string = && your code here



lcAddressEmployee = ''

If !Empty(Alltrim(myEmployeeInfo.add1))
lcAddressEmployee = lcAddressEmployee+Alltrim(myEmployeeInfo.add1)
Endif
If !Empty(Alltrim(myEmployeeInfo.town))
lcAddressEmployee = lcAddressEmployee+ '+'+Alltrim(myEmployeeInfo.town)
Endif

If !Empty(Alltrim(myEmployeeInfo.state))
lcAddressEmployee = lcAddressEmployee+ '+'+Alltrim(myEmployeeInfo.state)

Endif

If !Empty(Alltrim(myEmployeeInfo.zip))
lcAddressEmployee = lcAddressEmployee+ '+'+Alltrim(myEmployeeInfo.zip)
Endif


lcEmployeeName = 'EMPLOYEE: '+Alltrim(myEmployeeInfo.name_full)


This.Caption = 'Map for '+lcEmployeeName



This.BrowseR.Navigate(' lcAddressEmployee+'('+lcEmployeeName+')')


Case Empty(lnFk_employee) And !Empty(lnFk_client) And !Empty(lnFk_office) &&& directions client to office
&&& get address string for map

lcClient_address_string = && your code

lcAddressClient = ''

If !Empty(Alltrim(myClientInfo.add1))
lcAddressClient = lcAddressClient+Alltrim(myClientInfo.add1)
Endif
If !Empty(Alltrim(myClientInfo.town))
lcAddressClient = lcAddressClient+ '+'+Alltrim(myClientInfo.town)
Endif

If !Empty(Alltrim(myClientInfo.state))
lcAddressClient = lcAddressClient+ '+'+Alltrim(myClientInfo.state)

Endif

If !Empty(Alltrim(myClientInfo.zip))
lcAddressClient = lcAddressClient+ '+'+Alltrim(myClientInfo.zip)
Endif


lcClientName = 'CLIENT: '+Alltrim(myClientInfo.name_full)


This.Caption = 'Directions from '+lcOfficeName+' to '+lcClientName


This.BrowseR.Navigate(' lcOfficeAddress+'('+lcOfficeName+')'+;
'&daddr='+lcAddressClient+'('+lcClientName+')')



Case !Empty(lnFk_employee) And Empty(lnFk_client) And !Empty(lnFk_office) &&& directions employee to office

lcEmployee_address_string = && your code


lcAddressEmployee = ''

If !Empty(Alltrim(myEmployeeInfo.add1))
lcAddressEmployee = lcAddressEmployee +Alltrim(myEmployeeInfo.add1)
Endif
If !Empty(Alltrim(myEmployeeInfo.town))
lcAddressEmployee = lcAddressEmployee + '+'+Alltrim(myEmployeeInfo.town)
Endif

If !Empty(Alltrim(myEmployeeInfo.state))
lcAddressEmployee = lcAddressEmployee + '+'+Alltrim(myEmployeeInfo.state)

Endif

If !Empty(Alltrim(myEmployeeInfo.zip))
lcAddressEmployee = lcAddressEmployee + '+'+Alltrim(myEmployeeInfo.zip)
Endif

lcEmployeeName = 'EMPLOYEE: '+Alltrim(myEmployeeInfo.name_full)


This.Caption = 'Directions to '+lcOfficeName+' to '+lcEmployeeName




This.BrowseR.Navigate(' '&daddr='+lcOfficeAddress+'('+lcOfficeName+')')



Endcase
Endproc


Enddefine
*
*-- EndDefine: frmgooglemap
**************************************************
 
Mike

yes, that is correct that ie be used, but
"3. He doesn't have to worry about providing features such as printing the map, print preview, zooming, saving the web page, full page view, etc. They're all provided by the browser, without any programming on his part."

is not really true. all functions are there, print, send email, link etc along with add destination and ability to make route changes.
 
all functions are there, print, send email, link etc along with add destination and ability to make route changes.

Yes, I know the functions are available. My point was simply that, with the method he is already using, he doesn't have to write any code to make them accessible to the user - unlike with the web browser control.

I'm not saying Bart shouldn't use your method. On the contrary, I have often done a "browser in a form" in my own applications. But he has to weigh its many advantages over the simplicity of a single ShellExecute() command.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top