UnsupportedOperationException and Containers

Hi Folks,

I’m in the middle of a refresh on one of our older apps and part of the design update includes converting a slew of Windows to Container Controls to provide a more - single window experience. However, I learned a very important lesson about simply changing the super class for my Windows to ContainerControl - UnsupportedOperationException.

It turns out that you can’t ShowWithin a ContainerControl.

While that may sound obvious, if you’re converting windows to containers, it’s possible to miss. If you display message dialogs or sheet windows in your app and use the “ShowWithin(Self)” mechanism, you too can share in this discovery of an almost impossible to track exception (the stack trace is quite befuddling). The solution is to check all ShowWithin calls to make sure that you’re attaching to a real Window instead of the code’s ContainerControl.

Hopefully someone will remember this when they see that very strange stack trace (which actually makes sense now that I KNOW the cause).