在做报文编辑时选择一个树节点时文本框老保持不了选中状态,如何解决的

本文介绍如何使用ES_NOHIDESEL属性使CEdit控件在不拥有焦点时仍能保持文本选中状态,避免因失去焦点而导致选中状态消失的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

Negates the default behavior for an edit control. The default behavior hides the selection when the control loses the input focus and inverts the selection when the control receives the input focus. If you specify ES_NOHIDESEL, the selected text is inverted, even if the control does not have the focus.

 

设置这个属性之后,CEdit就可以在没有拥有焦点的时候同样可以成功设置选中(直接pEdit->SetSel(1, 4);就OK),并且在失去焦点后保持选中状态。

 

如果没有设置这个属性,你可能是这样

     pEdit->SetFocus();

     pEdit->SetSel(1, 4);

做才能有选中效果,并且失去焦点后就没了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值