views:

321

answers:

2

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!

+1  A: 

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.

Mark Ransom
OK, thanks. I thought I'm doing something wrong and missed an option to prevent the text from being selected.
fhe
A: 

I have experienced the same symptoms. How did you solve? Please let me know~

kay Choi