你是通过IDE添加的WM_LBUTTONDOWN消息吗 

解决方案 »

  1.   

    你的OnLButtonDown函数怎么添加进入的?以类向导的方式添加WM_LBUTTONDOWN消息的方式吗?
      

  2.   

    void CNewListCtrl::OnLButtonDown(UINT nFlags, CPoint point)
    前的函数却}号
      

  3.   


    // NewListCtrl.cpp : implementation file
    //#include "stdafx.h"
    #include "钻孔数据库查询.h"
    #include "NewListCtrl.h"#ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif/////////////////////////////////////////////////////////////////////////////
    // CNewListCtrlCNewListCtrl::CNewListCtrl()
    {
    m_nitem=-1;
    m_nsubitem=-1;
    m_nitem1=-1;
    m_nsubitem1=-1;
    }CNewListCtrl::~CNewListCtrl()
    {
    }
    BEGIN_MESSAGE_MAP(CNewListCtrl, CListCtrl)
    //{{AFX_MSG_MAP(CNewListCtrl)
    // NOTE - the ClassWizard will add and remove mapping macros here.
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
    // CNewListCtrl message handlers
    void CNewListCtrl::Edit()
    {
    CRect rect;
    if(GetSubItemRect(m_nitem,m_nsubitem,LVIR_LABEL,rect)==FALSE)
    return;
    int sty=WS_CHILD|WS_CLIPSIBLINGS|WS_EX_TOOLWINDOW|WS_BORDER;
    //设置编辑框样式
    if(m_edit.Create(sty,rect,this,ID_MYEDIT)==FALSE)
    //创建编辑框
    return;
    CString txt=GetItemText(m_nitem,m_nsubitem);
    m_edit.SetWindowText(txt);//设置编辑框的内容
    m_edit.SetFocus();
    m_edit.SetSel(0,-1);
    m_edit.ShowWindow(SW_SHOW);//显示编辑框
    m_nitem1=m_nitem;
    m_nsubitem1=m_nsubitem;
    }
    void CNewListCtrl::EndEdit()
    {
    if(m_nitem1!=-1&&m_nsubitem1!=-1)//判断是否为初始时
    {
    CString txt;
    m_edit.GetWindowText(txt);
    SetItemText(m_nitem1,m_nsubitem1,txt);//设置为编辑后的文件内容
    m_edit.DestroyWindow();}
    void CNewListCtrl::OnLButtonDown(UINT nFlags, CPoint point)
    {
    LVHITTESTINFO testinfo;
    testinfo.pt.x=point.x;
    testinfo.pt.y=point.y;
    testinfo.flags=LVHT_ONITEMLABEL;//强调点击必是标题
    if(SubItemHitTest(&testinfo)<0)
    return;
    m_nitem=testinfo.iItem;//得到行号
    m_nsubitem=testinfo.iSubItem;//得到列号
    if(m_nitem==m_nitem1&&m_nsubitem==m_nsubitem1)//判断是否是前一点击的行列
    return;
    else{
    EndEdit();//结束编辑框
    Edit();//创建新的编辑框对列表框进行编辑
    }
    }
      

  4.   

    http://blog.sina.com.cn/s/blog_5d0e9dc40100cmfo.html
    是根据这个网址上改的。我好像直接复制粘贴过来的。
      

  5.   

    void CNewListCtrl::EndEdit()
    {
    if(m_nitem1!=-1&&m_nsubitem1!=-1)//判断是否为初始时
    {
    CString txt;
    m_edit.GetWindowText(txt);
    SetItemText(m_nitem1,m_nsubitem1,txt);//设置为编辑后的文件内容
    m_edit.DestroyWindow();}
    }
    少一个 ‘}’
      

  6.   

    屏蔽掉对话框.cpp中的这段代码,不应该出现在对话框.cpp中
    /*
    BEGIN_MESSAGE_MAP(CNewListCtrl, CListCtrl)
    //{{AFX_MSG_MAP(CNewListCtrl)
    // NOTE - the ClassWizard will add and remove mapping macros here.
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()
    */
      

  7.   

    “error C2601: 'OnLButtonDown' : local function definitions are illegal”
    这种错误就是上一个函数没结束!