11 c++ mfc visual-c++
我正在使用VC9,我有一个CEdit控件,其内容被重置为默认测试(比如 - "填写"),只需单击一个按钮,然后我调用SetFocus进行CEdit控件.问题是光标在默认文本的开头闪烁,我希望它闪烁默认字符串的结尾.
如何才能做到这一点?
Nic*_*kis 15
您可以使用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
Run Code Online (Sandbox Code Playgroud)
小智 8
你可以用它CEdit::SetSel来完成:
CEdit* e = (CEdit*)GetDlgItem(IDC_EDIT1);
e->SetWindowText("hello world");
// e->SetSel(0,-1); // you don't need this line
e->SetFocus();
e->SetSel(-1);
Run Code Online (Sandbox Code Playgroud)
它会将光标放在字符串的末尾.
| 归档时间: |
|
| 查看次数: |
19948 次 |
| 最近记录: |