Click here to Skip to main content
13,351,465 members (46,079 online)
Click here to Skip to main content
Add your own
alternative version


29 bookmarked
Posted 7 May 2000

Handling right-click on the CListCtrl header control

, 7 May 2000
Rate this:
Please Sign up or sign in to vote.
Determining the right click on the header of the CListCtrl

A good way to handle a right click on the header control of a list control is to use the HDM_HITTEST message to determine on which header item the user right clicked.

Here is an example:

BOOL CMyListCtrl::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) 
    if( wParam==0 && ((NMHDR*)lParam)->code == NM_RCLICK)
        POINT Point;
        GetCursorPos (&Point);
        HDHITTESTINFO HitTest;
        //Offset of right scrolling  = Point.x+ GetScrollPos(SB_HORZ); //Offset of right scrolling = Point.y;
        //Send the Hit Test Message


The HDHITTESTINFO structure holds the column index in its iItem member.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Alberto Bar-Noy
Team Leader
Israel Israel
No Biography provided

You may also be interested in...


Comments and Discussions

Generalother solution... Pin
hopkins8-May-07 11:57
memberhopkins8-May-07 11:57 
GeneralYour a good man! Pin
hannahb23-May-05 6:47
memberhannahb23-May-05 6:47 
GeneralSimple problem, please help Pin
haiaw13-Sep-04 0:42
memberhaiaw13-Sep-04 0:42 
Sorry for writing here, but i'm a total beginner and i've dowloaded the Microsoft Rowlist example, i changed it a bit, used setitem data, getitemdata successfully, i know hawo to add , delete and edit my items.

As u know, the view class in the Rowlist example i derived from class CListViewEx : public CListView,so finally its from CListView. And my quote: HOW CAN I ADD TWO BUTTONS UNDER THE LIST??? SIMPLE STANDARD BUTTONS. IN THE ROWLIST EXAMPLE, WCHICH OBVIOUSLY IS NOT BASED ON DIALOG WINDOW, I CAN'T JUST PAINT THEM WITH WIZARD.
Generalthanks! Pin
jrivero2-May-03 7:47
memberjrivero2-May-03 7:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.180111.1 | Last Updated 8 May 2000
Article Copyright 2000 by Alberto Bar-Noy
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid