Combobox 在输入时自动完成
关键点
实现过程
BOOL m_bAuto;
BOOL CProject02Dlg::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN)
{
int nChar = pMsg->wParam;
if ((nChar == VK_DELETE) || (nChar == VK_BACK))
{
m_bAuto = FALSE;
}
else
{
m_bAuto = TRUE;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
void CProject02Dlg::OnEditchangeCombo1()
{
if (!m_bAuto)
{
return;
}
CString strText = _T("");
m_combobox1.GetWindowText(strText);
int nLength = strText.GetLength();
int nIndex = m_combobox1.FindString(-1, strText);
if (nIndex != CB_ERR)
{
m_combobox1.SetCurSel(nIndex);
m_combobox1.SetEditSel(nLength, -1);
}
}
|
图
备注
相关链接