What is the column width in a list control after double click on header

Posted on 2004-10-18
Last Modified: 2013-11-20
List control in report style.  I double click on the separator and the column is resized automatically.

I trap the HDN_DIVIDERDBLCLICK in a class derived from CListCtrl (notify message).  
I get the event BUT the width of the column is that BEFORE the double click.  I have passed the event onto the ListCtrl base class before querying the header for the new width.  I have even tried to strip out pending messages in the queue before getting the column width from the header - no effect.
Trapping the HDN_ENDTRACK notify message doesn't help either.

How can one respond to the double click event of the header and get the new column width?
Question by:AndyAinscow
LVL 14

Assisted Solution

RichieHindle earned 100 total points
ID: 12342411
If all else fails, use RegisterWindowMessage to register a private message, and post (not send) yourself one of those when the event happens.  Then in the handler for that message (which you set up using ON_REGISTERED_MESSAGE), look up the width and act upon the change.  By the time your message gets delivered, Windows will have sorted itself out and will report the correct width.
LVL 23

Accepted Solution

Roshan Davis earned 300 total points
ID: 12344768
LVL 23

Expert Comment

by:Roshan Davis
ID: 12344780
plz check - "Using the Header Control"

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

LVL 23

Expert Comment

by:Roshan Davis
ID: 12344799
and one more, this describes the usage of ENDTRACK message
"Autofit Header Control"

LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 100 total points
ID: 12346758
You can test the width of an individual cell, not the in the header.
LVL 44

Author Comment

ID: 12347523
RichieHindle - sounds good, not tested it.
jaime_olivares - correct about the width of a cell, unfortunately when I get the HDN_DIVIDERDBLCLICK the cell width is apparently still the same as the width in the header.
roshmon - some good links but I couldn't find anything new that helped directly.  However the HDN_ITEMCHANGED (not HDN_ITEMCHANGING) turned out to be my solution.  This event was fired with the correct width after resizing.  I needed to 'protect' my routine with a bool flag as I only wanted it to run after the drag/resize was finished.  The HDN_ITEMCHANGED was pumped many times during the drag resize but I could also trap the start of the drag and set a flag, release the flag at the end drag.
LVL 14

Expert Comment

ID: 12347705
Andy: Thanks for the summary, and for splitting the points.  If only everyone on EE were as thoughtful, it would be a better place.  8-)

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
if loop error 4 77
repeatEnd java challenge 42 83
Error on moodle after upgrade 3 106
Looking for a specific application/software 2 91
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

707 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now