首页 > 其他 > 详细

CEdit的Clear方法

时间:2021-07-02 15:06:38      阅读:20      评论:0      收藏:0      [点我收藏+]

做Win32或MFC开发,有不清楚的问题一定记得先查MSDN!

做Win32或MFC开发,有不清楚的问题一定记得先查MSDN!

做Win32或MFC开发,有不清楚的问题一定记得先查MSDN!

CEdit控件有个Clear方法,之前我一直以为是清除文本的,有点像SetWindowText(_T("")),但有一次这样使用后发现并不是自己想象的那样,随后照旧用SetWindowText,但这个疑问就那样扔下了。

最近查资料,偶然翻到MSDN,看到关于CEdit的Clear方法说明,如下:

Call this function to delete (clear) the current selection (if any) in the edit control.

Remarks

The deletion performed by Clear can be undone by calling the Undo member function.

To delete the current selection and place the deleted contents into the Clipboard, call the Cut member function.

For more information, see WM_CLEAR in the Platform SDK.

 

原来它是在不影响剪切板的情况下,清除当前选中的文本。假如你既要删除,又要将删除文本放入剪切板,就调用Cut方法。

 

因此,Clear方法并不是清除控件文本,那么清除控件文本还有没有其他方法,MSDN提供了一个例子:

// The pointer to my edit.
extern CEdit* pmyEdit;

// Delete all of the text.
pmyEdit->SetSel(0, -1);
pmyEdit->Clear();

清除控件文本,除了SetWindowText(_T("")),还可以用上述方式。

看到这里,问题终于有了答案。

CEdit的Clear方法

原文:https://www.cnblogs.com/kuaixue/p/14962939.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!