Ah, merci beaucoup Xorcist. Here's the situation:

First of all, I'm using Visual Basic 6 with service pack 5.

There are _two_ problems at the moment that are reasonably unrelated.

* Any control that can have focus (buttons, textboxes and the like) are flaky -- if focused and I close with the x button (top-right, standard Windows close button in the caption bar) then kaboom! This is reproducible by placing a single button anywhere on the control at design time, not even supplying code for it! This is most definitely the fault of the people who wrote the software -- it doesn't happen if I use their own ok/cancel buttons. Basically, I think they totally forgot about the x button (hell, it's only one or two clicks to remove it from the title bar, so it takes spectacular carelessness to forget!). This is probably the case in other sections of the software, though I've not checked.

I think that the above isn't too important -- I've already raised a call to their help desk so they know about it. It'll get fixed in time and seems like a programming error that will be fixed or is fixed already (I found out on Friday that we don't have the latest version of the software).

* The web browser problem is where I'm interested in your opinion

Basically, I can't use the web browser, which is pretty annoying. It seems that I can't use its Navigate or Navigate2 methods.

The project I'm working on is yer standard ActiveX control, which implements some-interface-or-other required for communicating to the main software (not relevant to this problem, I believe). It's an example project written by the people who wrote the original system, so I'm moderately confident that it doesn't have any problems. I hope!

I can place a web browser onto the empty ActiveX object, do some registry voodoo, and the thing shows up fine -- it appears as a new tab page on a tab control. The web browser is there and I can close everything without problems. (The web browser being placed normally at design time, not created dynamically yet.) However, if I use the navigate or navigate2 methods at any point and shut down the system then I get a run-time error 216 (which, IIRC, is an access violation at a point in a unit where the standard exception handler isn't available, in the initialization or finalization sections linky). This error happens at the very end of the program, rather than being an immediate thing.

The problem happens both with standard design-time objects and with dynamically creating 'em. For dynamically creating them, I've used code something like this (don't have the project to hand since I'm at home):

Code:
Dim webby as WebBrowser ' VB Sucks

Set Webby = Controls.Add("Shell.Explorer.2", "webby") ' VB REEEEALLY SUCKS

'uh, can't remember the exact values for below
Webby.Left = 0 ' it sucks
Webby.Top = 0 ' yes it does
Webby.Width = 3000 ' it really really does
Webby.Height = 3000 ' etc

' inside a button's click event
Webby.navigate("http://www.google.co.uk")

' killing it
set Webby = Nothing
(Declared in their respective sections/subprocedures, of course.)


I'm using the web browser component in shdocvw.dll (project>components>Microsoft Internet Controls).

I've been lead to believe that the main software was written in Delphi (some of those toolbar icons look very familiar :roll. It's possible that the original people dropped the ball twice -- but I'm annoyed here, because I can't see a reason for the web browser to give a 216 at the end but for other controls to work okay (which they seem to).

Any advice would be much appreciated, Xorcist. Thanks!