Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

LVN_COLUMNCLICK and arrow in column header

Posted on 2004-09-27
5
Medium Priority
?
1,030 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 500 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

721 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