我正在使用 VC9,我有一个 CEdit
控件,其内容在单击按钮时重置为默认测试(例如 - “填充”),然后我调用
。问题是光标在默认文本的开头闪烁,我希望它在默认字符串的末尾闪烁。 CEdit
控件的 SetFocus
如何做到这一点?
最佳答案
您可以使用 CEdit::SetSel
来完成那个。
例子:
CEdit* e = (CEdit*)GetDlgItem(IDC_EDIT1);
e->SetWindowText("hello world");
e->SetFocus();
e->SetSel(0,-1); // select all text and move cursor at the end
e->SetSel(-1); // remove selection
关于c++ - CEdit 控件 MFC,将光标置于 SetWindowText 之后的字符串末尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1480873/