When I create a CButton using Create, and I set the style to BS_DEFPUSHBUTTON, the button doesn't receive the button click message when the user hits the enter key. It generates the OnOK message. When the button is created using the resource editor and the style is set to default button, everything works correctly. How do I make a button the default button when creating it programmatically? Do I have to determine the default myself by handling the DM_GETDEFID message? Is there a better way?