What happened to embeddedWindowControl?

It still autocompletes in the IDE but can’t find reference to it in the help file.

EmbeddedWindowControl is the (mostly) internal reference type for a Container on Desktop. It’s still there and you’ll still bump in to references to it, but what you will implement is a DesktopContainer.

Thanks. I was using it in an “isa embeddedWindowControl” statement to determine if the object in the window was a containerControl or a regular control. Do I now need to change all instances of this to “isa desktopContainer”?

For API2 it’s been renamed to EmbeddedContainer

It’s always been a weird type of class. It exists exclusively to be the super class of Containers on Desktop to provide the same API as the window class. The way containers were implemented ages ago is a bit weird, and really would be awesome if things were done a bit differently from the start, but hindsight and all that.

Here’s an example of the funkiness.
I’ve added a DesktopContainer to a DesktopWindow. It’s the only thing on the window. Now, at runtime, if I inspect the window’s contents, I can see that it contains a single EmbeddedContainer. So I use the following code to grab the reference to that EmbeddedContainer and perform some tests:

var obj as Object = me.ControlAt(0)
var isContainer as Boolean = (obj isa DesktopContainer)
var isEWC as Boolean = (obj isa EmbeddedWindowControl)
var isEContainer as Boolean = (obj isa EmbeddedContainer)
var isWindow as Boolean = (obj isa DesktopWindow)

break

When we hit the breakpoint, what we see is pretty surprising:

isContainer = True
isEContainer = False '// Despite the debugger showing that DesktopWindow.Controls(0) is a EmbeddedContainer.
isEWC = False '// Not all that surprising as it's been replaced by EmbeddedContainer apparently.
isWindow = True '// This is True because all containers are subclasses of windows deep down.

So DesktopContainers are still just as weird, in this respect, as they’ve always been. BUT there’s something cool here that wasn’t previously possible. You can now cast an EmbeddedContainer to its DesktopContainer instance. This wasn’t a straightforward thing to do and many of us had long discussions and developed convoluted methods to do this. It appears to have been silently added, and I can’t find any notes about that either. So we can do this:

var dc as DesktopContainer = DesktopContainer(obj)
var cont as Container1 = Container1(obj)

And both now resolve the reference to the proper control instance where this would fail in API 1.0.

I know this was a lot, and probably more information than you needed, so…

TLDR:
EmbeddedWindowControl has become EmbeddedContainer, and both have the same API as DesktopWindow. It should be documented, but isn’t. I’ll open a case about that.

Edit: Issues case to document EmbeddedContainer.

3 Likes

Yes, in API 2.0, it seems that this should work and we should report cases where it doesn’t.

Thank you Anthony - that is very useful and saves a lot of trial and error.