请问如何得到组合框中当前所显示的内容呢?请大虾们指教

解决方案 »

  1.   

    CSTring s1;
    ((CComboBox *)GetDlgItem(IDC_COMBO1))->GetWindowText(s1);
      

  2.   

    谢谢大虾,问题解决了.
    我还想请教一个问题,我想当用户在组合框里输入字符后,响应消息.不知该用什么函数?CBN_EDITCHANGE和CBN_EDITUPDATE好像都不行.这两个函数都是当用户一开始输入字符时就响应,我想当用户输入完字符,按回车键后才响应应该怎么做呢?这两个函数的区别是什么呢?
      

  3.   

    那你用发消息来处理可以吧
    当按回车时,发消息着两个区别,你看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. 
      

  4.   

    你这样试试,
    int m_num=m_box.GetCurSel();
    m_box.GetLBText(m_num,m_boxName); //返回m_box内的字符串
      

  5.   

    CBN_EDITCHANGE
    只有当重绘窗口时才响应CBN_EDITUPDATE
    只要控件中得文本改变后就立刻响应
      

  6.   

    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){
    ....
                       }
                 }
    }
      

  7.   

    还是不行,不响应消息,当我去掉pMsg->message==WM_KEYDOWN 时,上述语句响应的是鼠标点击,而不响应回车键.我将VK_ENTER设成#define VK_ENTER  1否则编辑器说没定义.
      

  8.   

    cbc(逍遥子), small_wei(small谢谢这两位热心的大虾