|
-
May 22nd, 1999, 07:21 PM
#1
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
-
May 22nd, 1999, 08:25 PM
#2
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]
-
May 22nd, 1999, 08:46 PM
#3
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
-
May 23rd, 1999, 01:18 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|