Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
EVENTHANDLER() with WebBrowser causing Errors
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
EVENTHANDLER() with WebBrowser causing Errors
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01153978
Message ID:
01153978
Views:
66
Hi
I am having a real problem with getting the following error message before VFP dumps out "Resource Manager internal consitency error."

The scenario is as follows:
-> I have a WebBrowser object on a form.
-> The application is designed to implement a more complete version of the AUTOFILL feature of the Google toolbar for sites that users regularly visit. The application is able to highlight recognised HTML form fields and then insert the relevent values for a number of different users depending on who is logged on to the application.
-> It can be extended to create new mappings between HTML form fields and the user table fields.
-> Clearly there is no standard in naming of HTML form fields so you need to be able to create new mappings regularly for the various sites that you visit.
-> Instead of right-clicking to view the HTML source and then manually creating a new record in the mappings table, I wanted to allow users to right-click on a HTML Form Field and then create a mapping for that field name.
-> After lots of head scratching I had a look at Rick Strahl's highly informative paper "Using the Windows Shell API and Internet Explorer Controls in VFP"
-> I used EVENTHANDLER() to hook up my subclassed HTMLInputTextElementEvents Events Object to each INPUT object every time DocumentComplete fires on the WebBrowser.
-> The custom event object (See code below) has a reference to the Document object of the WebBrowser and a reference to the form (loParent) hosting the WebBrowser so that it can call the appropriate method on the form.
-> This all works perfectly until you try to close the form. Somehow, a reference persists to the form somewhere which results in the above Resource Manager error.

I was under the impression that EVENTHANDLER() automatically unbinds when the relevent objects go out of scope. I even tried creating a collection of all the form fields which i cycled through on BeforeNavigate to manually unbind but this didn't help either. (Incidentally, the call to EVENTHANDLER to unbind returned .F. but I can't tell why).

Any thoughts???


DEFINE CLASS wwHTMLInputTextElementEvents as HTMLInputTextElementEvents
loDoc = .null.
loParent = ""

PROCEDURE HTMLInputTextElementEvents_oncontextmenu() AS LOGICAL
* add user code here

*** This method replaces the default RIGHT CLICK action
* for Input objects where the replacement has been changed
this.loparent.HTML_Form_Input_Context(this.loDoc.ParentWindow.event.srcElement)
RETURN .f.
ENDPROC

ENDDEFINE
Kind regards

Phi Hollingworth.
Next
Reply
Map
View

Click here to load this message in the networking platform