Catching header messages in a CListView

This is a quick tip, worked out by Linus Flueeler and myself. We were
having problems catching header messages in a class dervied from
CListView. The first thing we fixed were the macros produced by the
class wizard, the autogenerated macros use the reflect mechanism which
is not correct since the messages get sent to the header controls
parent, which is the listview. So we changed the macros to use
ON_NOTIFY, the id is 0 which is always the case for the header control
in a listview control. Unfortunately this still didn’t work. Since we
are using NT but not ansi build we decided to try to catch the unicode
messages, which did work.

Below are the macros we used (we believe the ansi ones will be necessary
for a program running on 95):

	ON_NOTIFY(HDN_BEGINTRACKW, 0, OnBeginTrack)
	ON_NOTIFY(HDN_ENDTRACKW, 0, OnEndTrack)
	ON_NOTIFY(HDN_BEGINTRACKA, 0, OnBeginTrack)
	ON_NOTIFY(HDN_ENDTRACKA, 0, OnEndTrack)

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read