I’m posting this, because it took me two hours to find the issue.

I wanted to customize a listview’s header control, i.e. changing its behavior when the user resizes a column. According to the MSDN documentation, the header sends following notifications:

I’ve had no problem getting HDN_BEGINTRACK and HDN_ENDTRACK. Unfortunately, I didn’t receive the HDN_TRACK notification.

I’ve found many examples in the internet, which, instead of HDN_TRACK, intercepted the HDN_ITEMCHANGING notification. Well, after some more research, I’ve found a hint to the header control’s style HDS_FULLDRAG, which causes the control to render its content while being resized. If this style is set, no HDN_TRACK notifications are sent. And the System.Windows.Forms.ListView’s header has this style by default. That’s ok, but what’s not ok is that nowhere in the MSDN the relation between HDN_TRACK and HDS_FULLDRAG is documented.

I hope that if someone stumbles over this issue, Google will refer him to here. It would save him some time.

Update: I’ve got a request from Martin Welker, who asked how to remove HDS_FULLDRAG. I’ve found the article INFO: HDN_TRACK Notifications and Full Window Drag Style in the Microsoft Knowledge Base:

SUMMARY Starting with version 4.70 of ComCtl32.dll, the header control of a list view control in report view (LVS_REPORT) automatically receives the HDS_FULLDRAG style. When this style is set, the parent of a list view control receives HDN_ITEMCHANGING notifications, rather than HDN_TRACK notifications, when the column divider of the header control is dragged. To receive HDN_TRACK notifications, the header control of the list view control must not have the HDS_FULLDRAG style set. Note that the HDS_FULLDRAG style is ignored in versions of ComCtl32.dll prior to 4.70.

This article also includes some sample code how to remove the HDS_FULLDRAG style flag.

Comments

Anonymous

This just bit me. Thank god for Google.

I would have probably been banging my head on this for a while.

Thank you.

Anonymous

hi

i m tryin to do a code which requires not changing size of columns. so can u please send me a code in c#

Anonymous

I’m stumped. I googled this after having spent 20 minutes scratching my head.

I got delighted when I saw your blog entry, and ALT+TABed back to VS.NET. Did it work? Nope. :( I have even verified that the header control does indeed have the HDS_FULLDRAG style set. But I still don’t get HDN_TRACK, just the other notifications.

So I had to fall back to HDN_ITEMCHANGING. Although it works, it feels a bit like a defeat. Could it be that the behaviour of header controls have changed with SP2?

Anonymous

I’m having problems understanding how this actually works. Could someone point me to a code sample where the resizing of the columnheaders has been disabled? Preferably in C# but any managed code will do.

I would be most grateful.

Anonymous

Instead of spending two hours scratching my head, it took me only 20 seconds by Google.

Many thanks! I owe you several hours of my time ;)

Anonymous

Me too! Googled and found the answer. Unfortunately I still wasted a bit of time beforehand trying to figure this one out myself. That’ll teach me to default to google.

10Tec Company

** MS Header’s HDS_FULLDRAG stopped working in Windows 7 when app doesn’t use visual styles **

We are a company that develops and sells shareware ActiveX and .NET controls for other developers (see www.10Tec.com). We are using the native MS Header control in one of our controls, ActiveX grid called iGrid, and we detected that one style of this header control does not work properly in the latest versions of Windows, such as Windows 7.

We are talking about the HDS_FULLDRAG style which causes column headers to be redrawn while the user is resizing them. This style works like a charm in Windows XP, but it does not have any effect in Windows 7 if the app does not use visual styles (which are turned on using a special manifest file embedded as a resource). If the app uses visual styles, all works as expected.

Just one addition for those who know what notification messages are sent by the header control when the user is resizing a column. If HDS_FULLDRAG has effect, HDN_ITEMCHANGING is sent instead of HDN_TRACK. In our case, in Windows 7, HDN_TRACK is sent is both cases – when HDS_FULLDRAG is specified or not.

Has anybody encountered the same problem or at least can give some ideas of what it could be and how to overcome this?

Thanks in advance,
10Tec Development team

Anonymous

Thanks dude. Keep it here. there are people still working in these building blocks. so please don’t delete :)…

Anonymous

Thanks dude. Keep it here. there are people still working in these building blocks. so please don’t delete :)…

Leave a Comment

Your email address will not be published. Required fields are marked *

Loading...