The wyDay blog is where you find all the latest news and tips about our existing products and new products to come.
You're dying to know what the AIC is, aren't you? No, it's not a test to see if you qualify for insurance with a talking wallaby. Rather, you'll be glad to hear that I've coined a new computer acronym which you can add to your arsenal of entirely forgettable "stupid geek talk."
The AIC test (pronounced "ache test"), briefly, is a confirmation that your program works at 3a.m. Specifically it's a guard that you, the programmer, put in place for your customers' all-nighters. He'll be running Firefox with over 30 tabs open, Photoshop with nearly a gig's worth of images in memory, and several other CPU & memory intensive programs, plus your own program.
He's 20 minutes away from finishing after nearly 20 hours of caffeine fueled work. He clicks a link in Firefox and the browser freezes. Realizing a bad situation in the making, he flips back to Photoshop to save his work. "Application Not Responding," Windows gleefully reports. He switches from program to program, leaving a trail of unresponsive programs.
By the time he flips to your program, his Tea is in a puddle on his desk and he's used phrases that would make a longshoreman blush. Now begins the anger induced clickscapade. Clicking furiously, and largely at random, he's going to try to save his work, export and upload his data, and print a copy of his work all while your program blinks between responsive and unresponsive states. Your program has to process each click and keystroke perfectly. This means no flaky behavior.
From that series of events alone, the AIC test sounds suspiciously arbitrary. If you've taken even a beginners computer course you'll already know that nothing in the computer is arbitrary or unpredictable. To illustrate my point I'll describe the steps I took to fix an already usable SplitButton control to an AIC passable SplitButton control.
SplitButtons are everywhere from Firefox to Photoshop to many Microsoft products. Here's a SplitButton in Firefox:
As the name SplitButton implies, the functionality of the back button in Firefox is divided. Click the near the green arrow and the browser goes back a page; click the downward pointing black arrow (the drop-down region) and a list of recently visited sites appears.
These types of buttons are seen so often in Windows programs, you'd think Microsoft would have built the functionality into the Windows API prior to adding it to Windows Vista. Not so. After googling for a few hours I found three options:
The SplitButton I opted to use was by the Microsoft programmer, Jessica. After an hour of use I noticed a few sticky parts in her nearly perfect implementation. First of all, the drop-down region of the SplitButton didn't fill the full height of the button:
If the user clicks the right hand side of Jessica's button the user will expect a menu to pop-up. However, the highlight shows that if the user clicks either the top or bottom five pixels they will have triggered the normal button click-event. At 3a.m. this subtlety is death. It's an easy fix, so why not fix it?
Then there's the matter of right clicking. In Firefox's SplitButtons a right click shows the menu directly under the button — acting identical to clicking the drop-down region. Jessica's implementation, along with SplitButtons in Windows toolbars, shows the menu wherever the right click happened. I prefer displaying the menu directly under the button so it doesn't obscure the button's text:
And lastly, Jessica forgot to implement the disabled state for the SplitButton. It's another easy fix, and is essential if you disable buttons:
All of these "major" fixes took less than an hour to implement and test, and they reduced my own frustration with the button. I use the SplitButton in the InstantUpdate Designer so the user can select options when uploading their newly created update files:
If I were to use an unaltered version Jessica's SplitButton, then a user could easily start large uploads when he only wanted to change an upload option. Quirks like these make months of hard work seem wasted. And, it's only through anger induced clickscapades do these problems show themselves.
Update October 13, 2008: You can view all the latest changes at the SplitButton changelog page.
Download the fixed SplitButton. Open source, and confirmed working with .NET 2.0 and above (C#, VB.NET, etc.).
Subscribe to our blog's RSS Feed or follow Wyatt (CEO of wyDay) on Mastodon (@wyatt@hachyderm.io) to keep up-to-date with our latest posts.
Thanks, will give it a go.
The only thing I didn't like was that you passed "the anonymous guy's" control for the sole reason that it was created by an anonymous guy... Sounds like you are in love with Microsoft or something.
Let me remind you that anonymous guys have created some of the greatest frameworks, libraries and utilities, not to mention operating systems.
Regards
NT
You're right, I sound snarky and mean. I meant to suggest the quality of the code matters, but you can't really determine quality from whether someone is "known" or not.
I'm not in love with Microsoft, but I lust after quality. Microsoft just happens to hire some very smart people who produce very high quality code.
Random source code on codeproject.com is usually mediocre quality - oftentimes worse.
Though, the way I wrote it I sound like an asshole.
Shouldn't the setter for the ContextMenuStrip property either do nothing or delegate to the setter for SplitMenuStrip instead of modifying the underlying field directly? As it is there's a possible event hole, if anything tries to set ContextMenuStrip...
Miral, you're right. I've fixed it - the new version is up.
Question:
I noticed that when I change the button's Flat Style to flat it does not remain that way once a contextmenustrip is assigned to the button. Is there a way to fix this?
The splitbutton uses the default painting algorithm when a menu is not set. When a menu is set, the painting algorithm inherits the default windows theme.
I hope I've answered your question.
The back color does not work properly. It was OK initially but after I assigned a context menu to it the back color changed to the default windows gray color instead of the color that I set in the properties page for the split button.
Hey Gary,
Show me a pic of what you expect to see.
Great work updating jfo's project. This is exactly what I endeavored to find when I fired up Google.
I notice you left most of her inefficient code untouched and wrote a little bit of your own, so I cleaned that up. (Some attention to organization would have made it easier.) I also squashed a couple of minor bugs: the State defaults to Default instead of Normal (despite the name, Normal really is the default), and you switched the horizontal (x) and vertical (y) Center alignment calculations in AlignInRectangle. Oh, and the split should be visible by default (who's going to use a split button without a split?).
Slap on a coat of performance optimization and I have a perfectly professional WinForms SplitButton thanks to you guys. Your names are in the code doc. This control is now a regular addition to my toolbox, along with the DockPanel Suite (SourceForge).
Hello. I looked for such a control and this is nearly what I need, so thanks for posting fixed version. There is one minor bug in this version: if you press split area near the bottom of the screen then context menu overlaps the button while it is expected to drop-up from the button's top.