Solved

LVN_COLUMNCLICK and arrow in column header

Posted on 2004-09-27
5
995 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to create frequencies of a variable from SAS dataset? 10 146
C++ BOOL WINAPI ReadFile fails on windows 10 when reading from USB cable 9 546
EvenOdd challenge 10 160
Line meaning 9 96
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Suggested Courses

734 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