Remove selection from initialized text (Deselect) in CEdit control
Posted on 2004-09-18
I am initializing a CEdit control in MFC with a string using DDX. Normally, this string is selected when the dialog box opens. I need to stop this behavior and have no selection. Usually this is easy:
m_myEdit.SetSel(-1, 0, false);
However, initialization seems to be a special case. I've tried placing the above line in CDialog::DoDataExchange, CDialog::OnInitDialog, and CEdit::OnSetfocus without any success.
I've also tried subclassing CEdit as "CSelEdit" using this in OnInitDialog()...:
..and the ON_CONTROL_REFLECT macro in the CSelEdit class.
Can you recommend a modification of one of these methods, or an entirely new approach, in order to simply deselect initialized text in a CEdit control?