July 10th, 2008

What’s the deal with that alternate form for menu item template separators?

We saw last time that you can specify a separator in a menu item template by specifying zero for everything, even though technically you’re supposed to pass MFT_SEPARATOR for the flags. What’s the deal with that alternate form for menu item template separators?

This goes back to the early days of the InsertMenu function (and its friends like AppendMenu and ModifyMenu). In the Before Time, the way you specified a separator was to add a null pointer. Not a null string (a string with no characters, consisting only of the null terminator), but an actual null pointer.

AppendMenu(hmenu, MF_STRING, 0, NULL);

The recommended way of adding a separator is, of course, to use MF_SEPARATOR, but this old-fashioned method is still supported for backward compatibility. The alternate form of the menu item template for separators is just a throwback to the days when this “old style” of adding a separator was in fact the only style.

Topics
History

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.