Should this not be, then: 
if (flag & (DS_OK | DS_VALIDBUTTON)) ?

Otherwise we get no text when only DS_VALIDBUTTON is set.