于是在调试模式下跟踪进UpdateData(FALSE),发现最后调用了如下语句:
if (::SendMessage(hWndCtrl, CB_SELECTSTRING, (WPARAM)-1,
(LPARAM)(LPCTSTR)value) == CB_ERR)
{
// just set the edit text (will be ignored if DROPDOWNLIST)
AfxSetWindowText(hWndCtrl, value);
}
于是去查MSDN,CB_SELECTSTRING,里面明明白白写着:A string is selected _disibledevent=>CComboBox::SelectString,里面写着和上面类似:A string is selected _disibledevent=>
![1combobox,VC6.0里ComboBox碰到的问题](/Files/20115/f2c5542d-9cee-4ec8-b009-475ad5f69514.gif)
看来以后使用ComboBox的成员变量要更加小心,需要精确匹配的时候使用CComboBox::FindStringExact,然后再使用CComboBox::SetCurSel。
最新评论