Solved

LVN_COLUMNCLICK and arrow in column header

Posted on 2004-09-27
5
985 Views
Last Modified: 2013-11-20
I think this one should be easy - hopefully! When you sort various lists in applications like explorer (or others) by clicking on the column, then the column will show (add) a little arrow pointing either up or down.

How can I do that? I've got all the sorting etc. figured out, it would just be nice to have the arrow in the column as well.


Thanks!
0
Comment
Question by:Netikus
5 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 12166895
It doesn't come as standard.
What you need to do is have your own class based on CHeaderCtrl which does it's own drawing.
When you create your list control you then need to get the header control it has and subclass it to your customised class.  
Provide a virtual function for the DrawItem and do the drawing there.


I use
      HWND hWndHeader = ::GetDlgItem(m_hWnd, 0);
to get the handle of the header from a list control.
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 12167009
0
 
LVL 16

Accepted Solution

by:
nonubik earned 125 total points
ID: 12168051
If we take a look here http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/header/structures/hditem.asp we can see that the version 6.0 of commctrl provides support for the up/down arrow drawing : HDF_SORTDOWN/HDF_SORTUP

For this case some sample code:

BOOL bSortup;
HDITEM      hdrItem;

..... //init the 'sortup' bool

hdrItem.mask = HDI_FORMAT;
GetHeaderControl()->GetItem(0, &hdrItem);
hdrItem.fmt |= (bSortUp)?HDF_SORTUP:HDF_SORTDOWN;
GetHeaderCtrl()->SetItem(0, &hdrItem);
0
 
LVL 16

Expert Comment

by:nonubik
ID: 12168075
>hdrItem.fmt |= (bSortUp)?HDF_SORTUP:HDF_SORTDOWN;
should be
>hdrItem.fmt &= (bSortUp)?~HDF_SORTDOWN:~HDF_SORTUP; //reset the previous flag
>hdrItem.fmt |= (bSortUp)?HDF_SORTUP:HDF_SORTDOWN;      //set the new one
0
 
LVL 1

Author Comment

by:Netikus
ID: 12174308
Thanks everybody. This actually works for me and is very easy to implement.

It's not a problem that it works only on XP - I can definitely live with that.


Thanks.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Adapt this command to show who installed 29 111
Replacement selected text 2 63
sameEnds challenge 3 180
substring method in java 1 130
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question