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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to prevent OLE error by pressing many times a hyperlink

Status
Not open for further replies.

Nifrabar

Programmer
Mar 16, 2003
1,343
NL
Hi!

In my app I am having a hyperlink which pops up google maps and do show an adress from my data screen.
A user was not patient enough to see the google window appear and pressed several time the hyperlink. That resulted in error (translated from Dutch) OLE error code 0x800700aa : The (selected?) source is busy/occupied. Meanwhile google maps appeared.

My solution should be to disable the hyperlink using either a timer or by detecting the google-map window.

In case that seems to be right way; how to detect such a google-maps window do exist?

-Bart
 
Solve that by not using the hyperlink control. Rather use ShellExecute within the click of a button, and you can disable the button, when clicked.

Code:
*button.click
This.Enabled = .F.
DECLARE INTEGER ShellExecute IN shell32; 
    INTEGER hwnd,; 
    STRING  lpOperation,; 
    STRING  lpFile,; 
    STRING  lpParameters,;  
    STRING  lpDirectory,; 
    INTEGER nShowCmd
ShellExecute(thisform.hwnd,"open","your google maps url here","","",5)

You can reactivate the button, if the url changes to another place on the google map. That url should be put into a property, and the property_assign method could enable the button.

Bye, Olaf.

 
What about a BUSY property of Explorer object.
Something like:
Code:
IE = CreateObject("InternetExplorer.Application")
IE.Navigate ("[URL unfurl="true"]http://YourGoogleAddress.com")[/URL]
IE.visible = .T.
DO While IE.Busy
  DOEVENTS
ENDDO
Bye, Tom
 
* Another way to achieve this may be:

* Create a CommandButton and in the 'Click' of this button type the following code
this.enabled = .f.
* call your Hyperlink here
this.enabled = .t.
* Now the user can not click the button twice.
* I do not know if you can do the same with the hyperLink.
*
 
Mike,

you are correct, that is also what Bart wants, but the link actually only needs to be reactivated, if the Browser window would be closed. There is no need to reenable it, after the browser has loaded the map.

For that reason, disabling the link would be sufficient, you only need to reactivate the hyperlink control, if the link changes, there is no need to reopen the same link in the normal case. The first problem ist, the hyperlink control has no way of enabling/disabling it, therefore I proposed using a normal commandbutton, executing ShellExecute. You can also follow Tomans route and automate IE, which even gives more control over it and the window and it's state.

The second problem is to know when to reactivate it. Using ShellExecute you can even forget about this, it would just open up many browsers, if you click it many times. I think Bart could also live with that. It's just the OLE error, which is really unwanted.

The hyperlink control or the ffc derived classes of a hyperlink label etc are something I never found useful.

Bart, I fear if you want to stay with that UI you won't have control over the resulting browser window, so stop using it, go with anything else, eg ShellExecute, IE automation, or another solution: embed the webbrowser control into your form. Anything is better than the hyperlink, if it fails on impatient users.

Bye, Olaf.
 
Mike,

I agree with Olaf's first two paragraphs.

My post was a copy of Olaf's solution, which I did not realise at the time of posting.

Making hyperlink invisible and allowing application to .click(). My understanding is that once the IE is deployed through the .click(), necessary messages will appear for the user. Eventually, when user finishes, main application will be in control. However, if application allows to open multiple IEs based on the stored data, then ShellExecute may be the option.

Happy New Year

my best

Nasib
 
Hi to all,

First of all a healthy newyear wish to all of you and looking forward to continue sharing knowledge here!

To give more info:
I used the command-button with comes with the _hyperlink class.
Down below the code I have in the click-code.
The disable/enable solution I once found somwhere in this forum I believe and do use it quit often since.

@ Olaf
Your solution makes sense but how do I detect a change in the URL?
As from the code down below you see that I am picking data from my dataform [thanks to Mike Lewis who helped me years ago to get this working) to get the right google-map.
Once I should disable the button as you advices I can't see how to enable it again. Yes I do understand the property-assign method. But how to get that property changed?
Or do you mean that I should put my lcFullAdres into that property?

@ Toman
I do not understand your solution that well. Can you pleas explain some more what you expect to happen in the DOEVENTS?

@ Nasibkalsi
Thanks for your help but from me reply to Olaf you can see this is not the solution I am looking for.

In the past I also experienced that many IA-windows might get deployed. This is unwanted as well of course. So probably the automation-solution is best.
Is there also, using automation, to get the maps always on top?

Thanks again for all your thoughts!

-Bart

Code:
=DODEFAULT()
this.Enabled = .F.

LOCAL lc1,lc2,lc2a,lc3,lcFullAdres, llOK
llOK = .F.
llOK =InternetAvailable()
IF 	llOK 
	lc1 = thisform.txtstraat.value
	lc2 = thisform.txthuisnr.value
	lc2a = LEFT(thisform.txtpcd.value,4)
	lc3 = thisform.txtPlaats.value
	lcFullAdres = ALLTRIM(lc1) + [+] + ALLTRIM(lc2) + [+] + ALLTRIM(lc2a) + [+] +  ALLTRIM(lc3)
		

	this.ctarget = "[URL unfurl="true"]http://maps.google.com/maps?q="[/URL] + lcFullAdres

	this.follow
ELSE
	=MESSAGEBOX("Internet is niet beschikbaar."+ CHR(13)+ "Zonder internet is het niet mogelijk het adres op de kaart te tonen.",48,_screen.Caption)
ENDIF 

this.Enabled = .T.
 
>this.ctarget = " + lcFullAdres

You can stay with exact this line of code. Just replace the hyperlink button with a selfmade button class, add that same cTarget property and while you add that property check the checkbox of additionally adding the assign method cTarget_Assign(), and in that assign method you can set the button to enabled again. This is how you detect a change in the URL.

Besides I gave a a few other possibilities, you could also let the button stay enabled, if you just take a normal button and call ShellExecute() with the cTarget URL. This will cause the standard browser to start and if the button is clickend more than once the browser is simply started more than once, no OLE error appears, like with the hyperlink button.

Bye, Olaf.
 
If I follow your code correctly, then you do not need to disable/enable the button at all.

thisform.Addproperty("f_ActiveUrl","") in your load().

And compare it in your if statement: if it is the same then do nothing else update f_ActiveUrl and ShelExecute(). Actually you could compare with your thisform.cTarget and do not need f_ActiveUrl.
 
Bart,
my code snippet was meant like that

Code:
   * open your page with map
IE = CreateObject("InternetExplorer.Application")
IE.Navigate ("[URL unfurl="true"]http://YourGoogleAddress.com")[/URL]
IE.visible = .T.

   * request for loading page into new explorer window was given here 
   * DISABLE any other possibilities for repeating such request till page has been loaded
   * or request is rejected by server

DO While IE.Busy	
   * sometimes recommended: DO WHILE IE.Busy OR IE.ReadyState <> 4

   * This loop could ugly block your computer, 
   * so give a chance to other system requests and interrupts 
   * by command DOEVENTS – see helpfile for more informations
  DOEVENTS
ENDDO 

* Now page with map is loaded, your program can continue
* and other requests to web are acceptable,
* so ENABLE them here.

As for keeping maps always on top I haven’t heard that it is possible with automation. By the way some pretty obscure or very practical things are possible, for example:

Code:
IE.Document.execCommand ("saveas")
IE.Document.DesignMode = "on"
IE.ToolBar = 0
IE.FullScreen = .T.
IE.goHome

Bye, Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top