Vista ComboBox

Fri, July 20, 2007, 05:30 AM under Windows | Vista
Over time I've talked about XP and Vista textbox cue banners (and even implemented a version for Windows Mobile), but I hadn't realised they can be used for Vista combo boxes as well! The clue came via Kenny's MSDN mag article (includes many other features for the C++ Vista developer).

So all I had to do was the simple translation to managed code, which involves one line of code (assuming you have a combobox on your form with a few items to select and none set as selected):
SendMessage(comboBox1.Handle, 0x1703, 0, "Choose"); //CB_SETCUEBANNER

From left to right in the image above: Before the API call, before the call and the drop down open, After the API call, after the call with the drop down open. Of course once you select a real value from the combobox you do not see the cue banner (e.g. "Choose") again.

FYI, I actually found that any value for the two ComboBox properties DropDownStyle and FlatStyle worked, and the ones in the image above are DropDownList and System respectively.