CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 1999
    Posts
    19

    Detecting Column Header Clicked With CListCtrl

    Hi,

    I need to detect when a header is clicked in a clistctrl, which is easy with onclicked(). I then
    need to find the index of the header that was clicked And change the label for that header. Is there an easy way to do this?

    Thanks for your help,

    - Mark


  2. #2
    Join Date
    May 1999
    Posts
    17

    Re: Detecting Column Header Clicked With CListCtrl

    You should use Message Reflection notification of LVN_COLUMNCLICK. Add following line between BEGIN_MESSAGE_MAP and END_MESSAGE_MAP macro pairs,

    ON_NOTIFY_REFLECT(LVN_COLUMNCLICK, OnColumnclick)



    and add a member function in your view class,

    void CMyView::OnColumnclick(NMHDR* pNMHDR, LRESULT* pResult);




    To know which header column is clicked, do following,

    NM_LISTVIEW *phdn = (NM_LISTVIEW *) pNMHDR;
    int iColumnClicked = phdn->iSubItem;




    This does work in my codes, and wish u good luck.






    --
    mailto://[email protected]

  3. #3
    Join Date
    Apr 1999
    Posts
    19

    Re: Detecting Column Header Clicked With CListCtrl

    Thanks very much,

    I was getting so frustrated that I can't find any help to tell me that 1 **** command.

    Thanks again,

    - Mark


  4. #4
    Join Date
    May 1999
    Location
    Atlanta, GA, USA
    Posts
    443

    Re: This is a latter part of code to change the title

    Hi.

    This is a latter part of code to change the title of header
    control. This is one approach.

    You will find more clues from this site - CListView control
    section.

    //Chage the title to "Test"
    CHeaderCtrl* pHeader =(CHeaderCtrl*)GetListCtrl().GetDlgItem(0);
    HD_ITEM head;

    pHeader->GetItem(colIndex, &head);
    head.mask = HDI_TEXT;
    head.fmt = HDF_IMAGE | HDF_STRING;
    head.pszText = "Test";
    pHeader->SetItem(colIndex, &head);

    Regards.
    -Masaaki Onishi-



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured