Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WebBrowser Control
Message
 
To
03/12/2002 09:30:39
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00728982
Message ID:
00729018
Views:
21
This message has been marked as the solution to the initial question of the thread.
Charles,

>I have a web browser control (WEBBROWSER4) on a non-modal form. The BeforeNavigate2 event contains code that start a new form (like a menu). The problem is that the new form is created but does not get focus. The form containing the web browser control stay activated on top of the new form. My only solution for now is to push "{CTRL+F1}" to the keyboard so the new form becomes activated ... not really what i want.

When dealing with COM or ActiveX-controls and their events I am ALWAYS!!! trying to get out of there as
soon as possible because they in fact are like standalone executables sometimes having their own thread etc.
When you're calling another form from within the event, the event is not ended until You come back from the "lower bottom of the form". If during this (long) way anything bad happens You might be in deep trouble.
I had crashes that You are totally unable to create when dealing with plain VFP.

So what I do now is employ timers for that sort of stuff. I use a very simple one like this
DEFINE CLASS tmrAction as timer
nDelay   = 20
cCommand = ""
Enabled  = .F.
Interval = 0

PROCEDURE INTERVAL
  local lcCMD

  *-- Make sure the timer only fires once!
  this.enabled = .F.
 
  lcCMD = allt(this.cCommand)
  &lcCMD
ENDPROC

PROCEDURE SETTIMER(tcCommand as String, tnInterval as integer)
  local lnDelay
  lnDelay       = iif(vartype(tnDelay)="N", tnDelay, this.nDelay)

  this.cCommand = tcCommand

  this.Interval = lnDelay
  this.Enabled  = .T.
ENDPROC
Now in the event I do something like
PROCEDURE BeforeNavigate2
  Thisform.tmrAction.SetTimer("do form Foo.scx with 'lcPara1', lnAnotherParameterMaybe")
  
ENDPROC
This will cause to 1. Set the timer and IMMEDIATELY return to the event. Thus the
IE-Control gets back control and can do whatever it wants. 2. 20ms later the timer
fires and calls the form, not knowing anything about an activeX anywhere. 3. If the
whole thing crashes now, this will be a normal VFP-error and You won't get problems
with dangling references and thelike.

Hope this helps.
Regards from Berlin

Frank

Dietrich Datentechnik (Berlin)
Softwarekombinat Teltow (Teltow)

Frank.Dietrich@dd-tech.de
DFPUG # 327
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform