Menu

How do I get ColumnClick Message in CListView?

Gordon Ahn
2014-10-01
2014-10-03
  • Gordon Ahn

    Gordon Ahn - 2014-10-01

    In MFC, if using ON_NOTIFY_REFLECT(LVN_COLUMNCLICK, OnColumnClick) ==> WM_NOTIFY+WM_REFLECT_BASE , but I can't receive these messages from win32++.

    My example
    LRESULT CListView::OnNotifyReflect(WPARAM wParam, LPARAM lParam)
    {
    //WORD wpLo = HIWORD(lParam);
    switch(lParam)
    {
    case LVN_COLUMNCLICK:
    OnColumnClick(wParam,lParam);
    TRACE("COLUMN CLICKED!!!\n");
    break;
    default: break;
    }

    TRACE("wParam %x,lParam %x\n",wParam,lParam);
    return 0;
    

    }

    But I couldn't extract LVN_COLUMNCLICK Message from OnNotifyReflect.

    1) How do I get this?

    2) about OnColumnClick( NMHDR pNMHDR, LRESULT pResult )
    How do I configure OnColumnClick?

    Can you give me an example for this?

    -- Gordon Ahn.

     

    Last edit: Gordon Ahn 2014-10-01
  • David

    David - 2014-10-03

    Hi Gordon,

    In the WM_NOTIFY message, the lParam parameter is a pointer to the NMHDR structure. This structure contains the particular notification message (among other things).

    I modified CMyListView::OnNotifyReflect to test for the LVN_COLUMNCLICK notification as follows

    LRESULT CMyListView::OnNotifyReflect(WPARAM, LPARAM lParam)
    {
        LPNMHDR  pNMHDR = (LPNMHDR) lParam;
    
        switch(pNMHDR->code)
        {
        case NM_RCLICK:         return OnNMRClick(pNMHDR);
        case LVN_GETDISPINFO:   return OnLVNDispInfo(reinterpret_cast<NMLVDISPINFO*>(lParam));
        case NM_DBLCLK:         return OnNMReturn(pNMHDR);
        case NM_RETURN:         return OnNMReturn(pNMHDR);
        case LVN_COLUMNCLICK:
            TRACE("LVN_COLUMNCLICK\n");
            break;
        }
        return 0;
    }
    

    Best regards,
    David

     

Log in to post a comment.

MongoDB Logo MongoDB