简体   繁体   English

CComboBox 在调用 MoveWindow 后自动选择文本

[英]CComboBox automatically selects text after call to MoveWindow

I'm currently experiencing a very strange problem with a CComboBox used within a CFormView .我目前在CFormView中使用的CComboBox遇到了一个非常奇怪的问题。

After adding strings to the combobox (created with WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_SORT | CBS_AUTOHSCROLL ), I'm selecting an entry via CComboBox::SetCurSel and resize the combobox via MoveWindow in the OnSize() handler of the CFormView derived class. After adding strings to the combobox (created with WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_SORT | CBS_AUTOHSCROLL ), I'm selecting an entry via CComboBox::SetCurSel and resize the combobox via MoveWindow in the OnSize() handler of the CFormView派生 class。

As soon as I include the call to MoveWindow , the whole text in the edit part of the combobox gets selected.一旦我包含对MoveWindow的调用,combobox 的编辑部分中的整个文本就会被选中。 If I remove the call to MoveWindow , the text doesn't get selected.如果我删除对MoveWindow的调用,则不会选择文本。 This happens not only for one, but for all comboboxes used.这不仅适用于一个,而且适用于所有使用的组合框。

I'm somehow lost at this point.在这一点上,我不知何故迷路了。 Any hint is much appreciated!非常感谢任何提示!

Selecting all the text is standard Windows behavior when a combo box gets focus.当组合框获得焦点时,选择所有文本是标准的 Windows 行为。 I guess the MoveWindow is resetting the focus on the control.我猜 MoveWindow 正在重置控件上的焦点。

Try using CComboBox::SetEditSel to remove the selection after MoveWindow.尝试使用 CComboBox::SetEditSel 删除 MoveWindow 之后的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM