我们在combox的下拉框出来后可以在下拉框上面移动鼠标,这时候下拉框会选中相应的项目(鼠标还未点击左键),请问这个消息是什么消息?或者怎么捕获该时机?还有这时候选中的是第几项怎么知道?

解决方案 »

  1.   

    消息:WM_MOUSEMOVE  
    移动时选中的第几项应该是无法获得的,只有点击左键选中后,就可以通过API获得了
      

  2.   

    ON_CBN_SELCHANGE   The selection in the list box of a combo box is about to be changed as a result of the user either clicking in the list box or changing the selection by using the arrow keys. When processing this message, the text in the edit control of the combo box can only be retrieved via GetLBText or another similar function. GetWindowText cannot be used. 
      

  3.   

    可以找个变通的方法。
    用customdraw.
    再WM_DRAWITEM里边,调用基类的方法来画,但是可以判定是不是选中状态我猜想能行。。hoho
      

  4.   

    下拉框弹出后,移动鼠标,下拉列表会有不同的项被选中(蓝色显示),此时我要用tooltip提示选中项的功能(此时还未单击鼠标左键)这个....,不知道他的选中标记是什么吧?
      

  5.   

    应该只有选中才有消息响应吧. 或在CLICK消息里面再处理下. 自己处理比较麻烦
      

  6.   

    既然,你鼠标放过去,它的背景会变成蓝色, 说明还是出发它的某个消息的,
    看看msdn.
      

  7.   


    为什么不知道啊?drawitem参数里边带item号吧?!
      

  8.   

    你可以根据GetCurSel()获得当前下拉列表的值(0,1,2,3……),然后根据值来做不同的响应。
      

  9.   

    LRESULT CNewComboBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
    {
    // TODO: Add your specialized code here and/or call the base class
    if(WM_CTLCOLORLISTBOX == message)
    {
    HWND hListBox = (HWND)lParam;

    CListBox* pListBox = (CListBox*)FromHandle(hListBox);
    ASSERT(pListBox);
    int nCount = pListBox->GetCount(); if(CB_ERR != nCount)
    {
    CPoint pt;
    GetCursorPos(&pt);
    pListBox->ScreenToClient(&pt);

    CRect rc;
    for(int i=0; i<nCount; i++)
    {
    pListBox->GetItemRect(i, &rc);
    if(rc.PtInRect(pt))
    {
    CString str;
    str.Format(_T("nIndex = %d"), i);
    AfxGetMainWnd()->SetWindowText(str);
    break;
    }
    }
    }

    }
    return CComboBox::WindowProc(message, wParam, lParam);
    }
    重写CComboBox类,在WindowProc中加上上面的代码,在主对话框的标题上会显示当前鼠标在下拉ListBox中的哪一个item上。
      

  10.   

    http://blog.csdn.net/visualeleven/article/details/6622248