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
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
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"

Technology Partners: 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!

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

688 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