Subclassing question

  1. 3 months ago

    Tim S

    Feb 8 Canterbury, UK

    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?

  2. Julian S

    Feb 8 Pre-Release Testers, Xojo Pro UK
    Edited 3 months ago

    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.

  3. Tim S

    Feb 8 Canterbury, UK

    I am running 64-bit. The code is:

    #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

    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).

  4. Julian S

    Feb 8 Pre-Release Testers, Xojo Pro UK
    Edited 3 months ago

    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 :)

  5. Tim S

    Feb 8 Canterbury, UK

    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.

  6. Julian S

    Feb 8 Pre-Release Testers, Xojo Pro UK

    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 :)

  7. Tim S

    Feb 8 Canterbury, UK

    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.

  8. Julian S

    Feb 8 Pre-Release Testers, Xojo Pro UK

    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 :)

  9. Tim S

    Feb 8 Canterbury, UK

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

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

or Sign Up to reply!