当我按下一个按纽后,我想用程序获取组合框编辑栏里光标的位置.我在组合框失去焦点的消息响应函数里用geteditsel函数获取,但是结果总是0.请各位高手指点,怎样才能获得光标的位置. 环境是XP+vs2005

解决方案 »

  1.   

    好了,解决了,贴出来大家分享HBRUSH CMyCombo::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
    {
    HBRUSH hbr = CComboBox::OnCtlColor(pDC, pWnd, nCtlColor);

    // TODO: Change any attributes of the DC here
    switch ( nCtlColor )
    {
    case CTLCOLOR_EDIT:
    {
    CEdit* p = ( CEdit* ) pWnd; static int nEditID = p->GetDlgCtrlID();

    CWnd* pFocus = GetFocus();
    int nID = pFocus->GetDlgCtrlID(); if ( nEditID != nID )
    {
    return hbr;
    } p->GetSel( m_nStart, m_nEnd ); TRACE( "Edit s: %d, e: %d\n", m_nStart, m_nEnd );
    }
    break;
    default:
    break;
    }
    // TODO: Return a different brush if the default is not desired
    return hbr;
    }m_nStart, m_nEnd 就是所得。
      

  2.   

    CMyCombo 是从CComboBox继承的类