Here’s a follow-up on some old articles on the DS_
dialog style and avoiding accidental control ID collisions.
When you add the DS_
style to your dialog template, there are other changes to the dialog styles which come into play. Some are mandatory, some are automatic, and some are optional.
Mandatory: You must remove the WS_
style and you must add the WS_
style. If you omit the WS_
style or accidentally specify the WS_
style, then the dialog won’t be created as a child window of the parent window you specified.
Automatic: You may remove the WS_
and WS_
styles. The dialog manager removes them automatically, so this isn’t a requirement, but you are welcome to remove them yourself, either to avoid confusion or out of a sense of cleanliness.
Optional: You have the option of adding or removing the WS_
and DS_
styles, depending on the behavior you desire.
If you specify WS_
, then the child dialog will be created visible. Otherwise, it will be created hidden.
If you specify DS_
, then the child dialog gets the WS_
extended style, which gives it an extra outer edge border. If you want the child dialog to blend in seamlessly with its parent, then you probably want to remove that style.
If removing WS_POPUP and adding WS_CHILD is mandatory, why doesn’t the dialog manager do it for you similar to how it removes WS_CAPTION and WS_SYSMENU?
It’s not mandatory in the sense that “if you don’t do it, the operation fails”. It is technically legal to leave those flags in place, but the results are almost certainly not what you want.