这个东西在Visual C++ 编程高手上有例子的,可以看看,它的思路是先由 BeginEditLabel 事件中重到当前所击条目的矩形,然后在这个矩形中生成一个CEdit控件(可能要变大字体),然后可以写东西,在离开的 EndEditLabel 事件中得到编缉框中的文本并用 SetItemText 写入ClistCtrl,然后析构刚才建的 CEdit

解决方案 »

  1.   

    to:
    hloveloveu(很爱很爱你)网址呢?
      

  2.   

    //慢慢研究吧,大旨就是这样,自己需要修改代码,调整代码的位置,
    //应该比较容易理解的
    #define IDC_PROPEDITBOX 711  //定义CEdit的id先定义以下的成员
    public :
            int curRow,curCol;
    CEdit m_edit;
    protected:
         afx_msg void OnKillFocusEdit();//申明消息响应函数
    ----------------------------------------------//************1.定义消息映射**************
    ON_EN_KILLFOCUS(IDC_PROPEDITBOX,OnKillFocusEdit)//*************2.其他函数***************************//************从点得到行列,区域****************
    int CListBar1::CellRectFromPoint(CPoint & point, RECT * cellrect, int * col) const
    {
    int colnum; // Make sure that the ListView is in LVS_REPORT
    if( (GetStyle() & LVS_TYPEMASK) != LVS_REPORT )
    return -1; // Get the top and bottom row visible
    int row = GetTopIndex();
    int bottom = row + GetCountPerPage();
    if( bottom > GetItemCount() )
    bottom = GetItemCount();

    // Get the number of columns
    CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
    int nColumnCount = pHeader->GetItemCount(); // Loop through the visible rows
    for( ;row <=bottom;row++)
    {
    // Get bounding rect of item and check whether point falls in it.
    CRect rect;
    GetItemRect( row, &rect, LVIR_BOUNDS );
    if( rect.PtInRect(point) )
    {
    // Now find the column
    for( colnum = 0; colnum < nColumnCount; colnum++ )
    {
    int colwidth = GetColumnWidth(colnum);
    if( point.x >= rect.left && 
    point.x <= (rect.left + colwidth ) )
    {
    // Found the column
    RECT rectClient;
    GetClientRect( &rectClient );
    if( point.x > rectClient.right )
    return -1;
    if( col ) 
    *col = colnum;
    rect.right = rect.left + colwidth;
    if( rect.right > rectClient.right ) 
    rect.right = rectClient.right;
    *cellrect = rect;
    return row;
    }
    rect.left += colwidth;
    }
    }
    }
    return -1;
    }void CListBar1::OnLButtonDown(UINT nFlags, CPoint point)
    {
    int row, col;
    RECT cellrect;
    row=CellRectFromPoint(point, &cellrect, &col);
             if(col ==-1||row==-1)return;
            CClientDC dc(this);    
             dc.DrawFocusRect(&cellrect);
    CListCtrl::OnLButtonDown(nFlags, point);

    //重绘开始
    if(m_edit){
    m_edit.ShowWindow(SW_HIDE);
    m_edit.MoveWindow(&cellrect,TRUE);
    }
    else
    m_edit.Create(ES_LEFT|ES_AUTOHSCROLL|WS_VISIBLE|WS_CHILD|WS_BORDER,
    cellrect,this,IDC_PROPEDITBOX);
    m_edit.ShowWindow(SW_SHOW); 
    m_edit.SetFocus();
    //char  caption[256];
    CString caption;
    GetItemText(row,col,caption.GetBuffer(256),256); 
    caption.ReleaseBuffer(); 
    CFont *font=this->GetFont(); 
    m_edit.SetFont(font); 
    m_edit.SetWindowText(caption);
    curRow=row;
    curCol=col;
    }//***********消息响应函数,注意要做消息影射***************
    void CListBar1::OnKillFocusEdit(){
    CString caption;
    m_edit.GetWindowText(caption); 
    this->SetItemText(curRow,curCol,_T(caption));
    curRow=-1;
    curCol=-1;
    if(m_edit)
    m_edit.ShowWindow(SW_HIDE);
    }