Subclassing question

I have a ContainerControl which has one control, an HTMLViewer, call it myCC. It also has some methods and properties. I have one instance of this ContainerControl in a Window (actually on a PagePanel), call it myCCsub, which therefore has myCC as its super.

Now, there are two things I need to do when the app starts up:

  1. I need to indicate that for Windows I want to use the IE11 renderer. At the moment I have this code in the open event handler for myCC. Is this the right place?

  2. I need to load a file full of HTML/javascript into myCCsub. At the moment I have this code in the open event handler for myCCsub. Equally, is this the right place?

If a renderer earlier than that for IE11 is used (or webkit), things work as desired. I’m not getting consistent behaviour, and wonder whether there’s a race condition here with two open events and no guarantee of sequencing. Under W10, I’m getting a couple of javascript errors consistent with that the renderer that actually gets used is that for IE7. In fact, I get identical javascript error messages if I open my file from (2) above in Internet Explorer under W10, which seems to default to IE7 behaviour unless I force it to be IE11 by using the IE Developer Tools.

Under macOS, or if I make myCC use webkit as renderer, there is no problem, which may be just because (1) above is conditionally compiled out.

Do I need to reorganise this at all?

What code are you using to set your browser version in the registry? If you’re using the wrong version of code and you are running in 32bit, you can be setting the wrong registry value which wont be picked up by the browser, thus rending it using an older version. It all depends on the code and exe architecture type.

I am running 64-bit. The code is:

[code]#if (TargetWindows=true) then

dim reg as new RegistryItem (“HKEY_CURRENT_USER\SOFTWARE\Microsoft”)
reg = reg.AddFolder (“Internet Explorer”)
reg = reg.AddFolder (“Main”)
reg = reg.AddFolder (“FeatureControl”)
reg = reg.AddFolder (“FEATURE_BROWSER_EMULATION”)
reg.Value (App.ExecutableFile.Name) = CType (11000, Int32)

#endif[/code]

My W7 and W10 are VirtualBox VMs running on a Mac. I did poke around in the registry in both VMs, I see both my app and its debug version registered (apparently so anyway, I’m no registry expert).

Your browser selection code is good.

Interesting.

If you have the browser select code in myCC.Open then it isn’t called in time.

You need to put the browser select code inside the HTMLView.Open inside the CC itself. I guess this is because the HTMLViewer creation happens inside the CC before the code runs on the window.

Personally I’d put this in the App.Open though just to be on the safe side.

Putting the load code into myCCsub should be fine as that should be called last after everything is set up.

If in doubt, just break the code out into a small test project, sprinkle it with system.DebugLog(CurrentMethodName) aka FairyDust and see what comes out :slight_smile:

Ha! Thanks, I’ll check that out. Ah, actually that code is inside the HTMLViewer.Open. Sorry, I was wrong in that regard in my OP.

But isn’t App.Open the last thing that happens? I recall there’s something in the docs about the sequence when an app starts, and I’ve been trying to find it again without success. But I always thought app.Open happened last.

Hmm it should work ok then, at least it did on the quick demo project I did here.

Unless I’m mistaken, App.Open happens before any windows are opened so its a safe place for init stuff.

I’m sure there are other places you could do it, constructors, Interfaces etc. but its best to keep it simple, it tends to always work then :slight_smile:

I’ll try it in App.Open then - but not until tomorrow.

But presumably once the Registry entries are there, they stay there and will be effective on future runs of the app, even if the first time the entries came too late? As I say, I checked with regedit and they seemed to be there - and where I was expecting to see them, too.

By the way, a few months ago you made a suggestion to use websockets to communicate between an HTMLViewer and the rest of the app. I ended up implementing this and it works great. So thanks for that.

Yes, as long as the exe name stays the same, you only need to set it up once, however if someone else happens to use the same exe name and changes the value to something unexpected then you’ll be out of luck if you didn’t set it during startup. The odds of that happening though are slim.

Good to know on the websockets thanks, I’m glad it worked out :slight_smile:

Yeah, I wasn’t planning to rely on it having been previously registered :slight_smile: It was just that, it makes it more of a mystery.

The websocket stuff was a nice little research project, too.