System Programming
--
Questions
--
Followers
Top Experts
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()...:
m_mySelEdit.SubclassDlgIte
..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?
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Note that if you tab through the controls back to ID_EDIT_1 again, the selection goes away properly. It's only on initialization that it fails. I don't know if this matters, but the DDX member is a CString rather than a CEdit object for the text box.
Maybe a SetFocus() is needed? Or maybe there's a way to intercept any EM_SETSEL message that could be causing the problem.
When dialog is initialized, the focus is set to the first control in "tab order" list. At this point, the focus event is "trapped" by your event handler and selection is cancelled.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
http://www.codeproject.com/editctrl/editctrltutorial.asp?df=100&forumid=1672&select=752761#xxxx
I think no. I have tried.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
:-S
System Programming
--
Questions
--
Followers
Top Experts
Kernel and system programming is the process of creating the software necessary for a computer or device to function and operate other programs. Some operating systems (such as Microsoft Windows) are proprietary, but others, such as the various Linux distributions, are open source.