December 3rd, 2003

Which window style bits belong to whom?

There are 64 bits of styles in the parameters to CreateWindowEx. Which ones belong to whom? Windows defines the meanings of the high word of the dwStyle parameter and all of the bits in the dwExStyle parameter. The low 16 bits of the dwStyle parameter are defined by the implementor of the window class (by the person who calls RegisterClass). In Windows 95, we found several apps that noticed that some bits in the dwExStyle weren’t being used, so they decided to use them for themselves. Then when we added meanings to those bits (such as WS_EX_TOOLWINDOW), these programs started acting funny. So don’t be like those programs. Don’t use bits that don’t belong to you.

If you need more than 16 bits of style information, you can design your class so additional information is passed in the lpParam parameter (the last one) to CreateWindow/Ex, which can be received from the lpCreateParams member of the CREATSTRUCT structure. Alternatively, you can set additional styles with a custom message, such as listview’s LVM_SETEXTENDEDLISTVIEWSTYLE message.

Topics
Code

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.