• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 574
  • Last Modified:

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

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?
0
AndyAinscow
Asked:
AndyAinscow
3 Solutions
 
RichieHindleCommented:
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.
0
 
Roshan DavisCommented:
What about HDN_ITEMCHANGING?
0
 
Roshan DavisCommented:
plz check http://codeproject.com/listctrl/headerctrl.asp - "Using the Header Control"

~R
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Roshan DavisCommented:
and one more, this describes the usage of ENDTRACK message
"Autofit Header Control"

http://www.codeguru.com/Cpp/controls/listview/headercontrol/article.php/c927/

~R
0
 
Jaime OlivaresCommented:
You can test the width of an individual cell, not the in the header.
0
 
AndyAinscowAuthor Commented:
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.
0
 
RichieHindleCommented:
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-)
0

Featured Post

Independent Software Vendors: 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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now