那你用发消息来处理可以吧 当按回车时,发消息着两个区别,你看MSDN CBN_EDITCHANGE The CBN_EDITCHANGE notification message is sent after the user has taken an action that may have altered the text in the edit control portion of a combo box. Unlike the CBN_EDITUPDATE notification message, this notification message is sent after the system updates the screen. The parent window of the combo box receives this notification message through the WM_COMMAND message. CBN_EDITUPDATE The CBN_EDITUPDATE notification message is sent when the edit control portion of a combo box is about to display altered text. This notification message is sent after the control has formatted the text, but before it displays the text. The parent window of the combo box receives this notification message through the WM_COMMAND message.
你这样试试, int m_num=m_box.GetCurSel(); m_box.GetLBText(m_num,m_boxName); //返回m_box内的字符串
BOOL youdlg::PreTranslateMessage(MSG* pMsg) { if (pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_ENTER){ CWnd* wnd = FromHandle(pMsg->hwnd); int i = wnd->GetDlgCtrlID(); if (i == IDC_COMBO1){ .... } } }
((CComboBox *)GetDlgItem(IDC_COMBO1))->GetWindowText(s1);
我还想请教一个问题,我想当用户在组合框里输入字符后,响应消息.不知该用什么函数?CBN_EDITCHANGE和CBN_EDITUPDATE好像都不行.这两个函数都是当用户一开始输入字符时就响应,我想当用户输入完字符,按回车键后才响应应该怎么做呢?这两个函数的区别是什么呢?
当按回车时,发消息着两个区别,你看MSDN
CBN_EDITCHANGE
The CBN_EDITCHANGE notification message is sent after the user has taken an action that may have altered the text in the edit control portion of a combo box. Unlike the CBN_EDITUPDATE notification message, this notification message is sent after the system updates the screen. The parent window of the combo box receives this notification message through the WM_COMMAND message. CBN_EDITUPDATE
The CBN_EDITUPDATE notification message is sent when the edit control portion of a combo box is about to display altered text. This notification message is sent after the control has formatted the text, but before it displays the text. The parent window of the combo box receives this notification message through the WM_COMMAND message.
int m_num=m_box.GetCurSel();
m_box.GetLBText(m_num,m_boxName); //返回m_box内的字符串
只有当重绘窗口时才响应CBN_EDITUPDATE
只要控件中得文本改变后就立刻响应
{
if (pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_ENTER){
CWnd* wnd = FromHandle(pMsg->hwnd);
int i = wnd->GetDlgCtrlID();
if (i == IDC_COMBO1){
....
}
}
}