I'm currently experiencing a very strange problem with a CComboBox
used within a CFormView
.
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.
As soon as I include the call to MoveWindow
, the whole text in the edit part of the combobox gets selected. If I remove the call to MoveWindow
, the text doesn't get selected. 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. I guess the MoveWindow is resetting the focus on the control.
Try using CComboBox::SetEditSel to remove the selection after MoveWindow.