combox控件的GetWindowText()函数的做用原本是获取当前选中项目的内容ide
可是在CBN_SELCHANGE消息的处理函数OnCbnSelchangeComboDrive()中,使用GetWindowText()函数获取的并非当前选中项目的内容,而是以前选中的内容,由于GetWindowText()是在CBN_SELCHANGE消息以后才生效的,那么在OnCbnSelchangeComboDrive()中要怎么得到当前选中的内容呢?函数
答案是:将GetCurSel()和GetLBText()配合使用get
例如:string
CString strDrive;
int select = m_drive.GetCurSel();//m_drive是combox控件的变量
m_drive.GetLBText(select,strDrive);//那么strDrive就得到了当前选中的内容it
参考:io
http://stackoverflow.com/questions/481255/how-can-i-get-the-value-string-of-the-current-selection-in-a-comboboxclass