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

_webview / _webbrowser4 - release form issue 1

Status
Not open for further replies.

KarenLloyd

Programmer
Nov 23, 2005
141
GB
Hi Gurus

Happy Friday! (At least I hope it will be eventually when I finally decide to knock off for the week...)

I'm working for the first time ever with the web browser ActiveX control in a form (VFP6) and it's pretty much doing what I want. I'm happy with that - but I have one problem. When I release my form and return back to my selection routine it all looks fine, but behind the scenes the form with the web browser window has not been released and on return to my main menu program the form shows in the background and I start getting oHost error messages.

There must be something simple that I am missing to close and release the browser control, but from the class browser, methods, events and Internet searches I cannot find what I am looking for.

By the time the user exits the form I will have already extracted data and finished processing it, so I just want it to close and release.

Can anyone tell me why releasing the object is not enough in this instance? It may be that I don't have enough knowledge of ActiveX and it's just something daft... but the form just won't go away!

Please help - I need closure ;)

Thanks in advance

Karen


 
Karen,

Good to hear you're making progress with this project.

There's nothing special you need to do to close a form that hosts an ActiveX control. You just call THISFORM.Release from your Close button in the usual way. Or, leave it to the user to click on the X button on the title bar, in which case you don't need any special code.

Perhaps you can tell us what you are doing at present to close the form. What code do you have? Also, is there any code in the form's Destroy, Unload or QueryUnload methods that might be relevant?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Your thread caption suggests you use the _webview.vcx from home()+"Gallery". Rick Strahl tells to put a simple native ole control (you find it on the normal form controls toolbar, even not using the ActiveX tab) on a forma and pick the "Microsoft Web Browser" from the Insert Control dialog appearing, when you drag the olecontrol from the toolbar to a form.

Then only put nodefault in the Refresh event.

The_webbrowser4 class has lot's more code and it maybe easier to use and offers much functionality, but it may be the reason your form does not release.

Another regular reason for forms not releasing is object references in variables or properties of other objects still pointing to a form object. If you use code setting a variable oBody = Thisform.olecontrol1.docunet.body, then eg the oBody variable may hold the form alive, especially if it's declared public. Remove all references to the webbrowser control and the form should release just fine.

Bye, Olaf.
 
Thanks Mike and Olaf for your replies.

It is the _webbrowser4 control, I will look into these controls further using the information you have given me...

Karen
 
Hi again.

What happens when I release the form is that it remains open and I start to get messages relating to oHost and _WEBBROWSER41 statusextchange. This comes from code within the _webbrowser4 object, so I would need to override or remove, or copy the whole class def and create another one (is that a possibility?)

I looked into changing to the OleControl, but I don't have MS Web Browser as an option - I am still using VFP6 - is there anywhere left that I can download this?

If I can create a form with another IE container instead of _webbrowser4, then at least then everything would easier to control.

I'm sorry, I expect this is probably ancient to you by now...

Thanks again

Karen
 
MS Web Browser Control is there as long as you have IE4 or later installed, it does not depend on the VFP version. _webbrowser4 also uses it, that alone is a proof it's there.

Take these basic steps:

1. Create a new empty form. It's your choice if it's an SCX or a form class, that doesn't matter
2. Make sure the form controls toolbar is available or activate it from the menu "View"
3. In the form control toolbar you find olecontrol and oleboundcontrol in the list of Standard controls. The one without the blue something inside is the olecontrol, it's what you need as the first step.
Drag that onto the form
4. Once you dragged the olecontrol you get a dialog to make your choice of the olecontrol you really want to add. That is the "Insert Object" dialog I referred to earlier.
You have to scroll down a lot, you have lots of ActiveX controls available for sure. It should have "Microsoft Web Browser" in that list. Alphabetically listed. You find it at Mi.. not MS.
5. Once you have it in the form, double click on the Web Browser Control and change to the REFRESH event to write NODEFAULT in that event as it's code, no further code is needed in the whole control in the first place.

Now you're ready to use the native Web Browser control, it has no code whatsoever from the _webbrowser4 class.

In the form init you may do something like THISFORM.Olecontrol1.Navigate(" and this will load that URL at form start.

I think you can take it from there.

Bye, Olaf.
 
Hi Olaf

This is what I tried to do yesterday, but the Insert Object dialog only lists a few things for Microsoft and they are either Graph or Office related.

This computer will have had IE4 at some point, but now has IE9, so earlier versions may well have been removed. Reinstalling IE9 did not make any difference.

I cannot see how to fully uninstall Internet Explorer so that I could start again.

Do you have any suggestions please?

Thanks

Karen
 
I don't know, "Microsoft Web Browser" should display for all versions since 4, not only for IE4. I said "IE4 or later".

You also don't Need specific Access rights to see activex controls installed.

Can you give a screenshot of the Dialog you get?

Bye, Olaf.
 
Hi Olaf

Here is image of Insert Object dialog

TT2013-12-04_150324.jpg


Would the Microsoft Web Browser install be part of an uninstalled ocx somewhere on the computer?

Alternatively, I may have to search the _webbrowser4 class for objects and variables and add some error handling and try to close or "destroy" the form another way to clear it from the screen.

There must be a way that I can do that.

Thanks

Karen
 
Change to "Create Control". In my dialog it's the default and it's called "Insert Control", but it should do th same, it should expand the list in the middle.

Bye, Olaf.
 
Hi Olaf

Sorry - it's the same problem, here is the screen shot..

TT2013-12-04_165036.jpg


It's not registered for my VFP6. Can I use Add Control to add the Web Browser into the list somehow - and if so - does anyone know where can I find the file?

Thanks

Karen
 
The Microsoft Web Browser is contained with an IE installation. Again: As you can use the _webbrowser4, that's already proof it's installed.
When I select it, the footer displays, that this control is contained in ieframe.dll

Here's another way to add acivex controls to the form controls toolbar:

In Tools->options or whereever the Options dialog is in VFP6, activate the controls tab, hopefully the Microsoft Web Browser Control shows there
options.JPG

Check it, Set As Default.

Now you should be able to see it in the form controls toolbar:
formcontrols.JPG


You get there by clicking on the library symbol in the top line of the toolbar, then select "ActiveX Controls"
The toolbar will then show all ActiveX controls you selected in the options.

If all this does not work out, then try with some other ActiveX control at least. If that doesn't work it looks like it's VFP6 not working correctly in regard to ActiveX.

Good Luck!

Bye, Olaf.
 
There also is a way to put this in code, as a last resort, because it's not possible to visually design and expand it:

Code:
PUBLIC ox
ox=NEWOBJECT("myformx")
ox.show
 
DEFINE CLASS myformx as Form
      ADD OBJECT oweb as cweb
      width=800
      height=600
      PROCEDURE init
            this.oweb.width  = thisform.width
            this.oweb.height = thisform.height   
            this.oweb.navigate2("[URL unfurl="true"]http://www.tek-tips.com")[/URL]  
ENDDEFINE
DEFINE CLASS cweb as olecontrol
      oleclass="shell.explorer.2"
      PROCEDURE Refresh()
            nodefault
ENDDEFINE

Taken from and minified to just the web browser control on a form.

At least you can use this to see the control is there.

Bye, Olaf.
 
Thank you, Olaf

You have given me plenty to work with here.

Kind regards

Karen
 
Good afternoon,

The problem with the form not releasing properly only occurs when I call a program to extract data nodes from the HTML page before releasing the form. This goes back to what Olaf said earlier...

Olaf said:
Another regular reason for forms not releasing is object references in variables or properties of other objects still pointing to a form object. If you use code setting a variable oBody = Thisform.olecontrol1.docunet.body, then eg the oBody variable may hold the form alive, especially if it's declared public. Remove all references to the webbrowser control and the form should release just fine.

After clearing all related variables and objects, I managed to solve the problem by checking for the top level form using WONTOP() and then issuing DEACTIVATE WINDOW...

Thank you again for all your help and patience.

Best wishes

Karen


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top