Friday, July 3, 2009

The Vista Mystery Control

Recently I was working on a dialog that contains vital information that is unnecessary 99% of the time. But 1% of the time, you really want it. I looked through the Windows UI and found that Microsoft has made a control for just this purpose. It's called an Expander control:





Now, you wouldn't know much about the Expander control if you're a typical C++ programmer, because as far as I can see, it's not supported unless you're writing WPF/XAML, which is only officially supported with C# or VB. (Not that I actually believe that the UAC dialog or the Shell Copy dialog are implemented in C#, but they appear to use XAML somehow.) In fact, I had to Google quite a bit to even come up with its name. None of my coworkers knew what it was called either.

Anyway, if you're observant, you may notice that the final dialog in the list--a file save dialog--is a little different than the first two. You see, file save dialogs definitely don't use XAML, but someone higher-up must have decided that they wanted Expander functionality there as well. I suspect the marketing guys saw this in OS X and thought "hey, that makes the file dialog look simpler:"



Anyway, pity the poor guy who had to implement this control in the file dialog--it's a totally alien object in Win32/MFC. Image buttons with round borders? Clickable text with no border? Not a chance, unless you do owner-draw. But our clever engineer had a trick up his sleeve! If you mouse over the pseudo-Expander control in the file dialog, you'll notice it gets a temporary button-like outline, which is actually a great clue for the real implementation. Turns out this is a one-item toolbar wedged into the middle of the window!! (I used Spy++ to check.) Talk about a hack.

Leave it to Microsoft to introduce a new control and then, in the intersection where marketing and tech collide, implement it with the most esoteric kludge imaginable. They didn't even bother to use the same art. Pathetic.

As for me? I decided that, given the choice between wedging a toolbar at the bottom of my window or just using a regular button, I'd take the easy road and use a plain old button. Maybe one day I will break down and write some code to emulate the one-item toolbar hack. I will need to take a shower afterwards, I suspect.

No comments:

Post a Comment