Catching header messages in a CListView | CodeGuru

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 […]

Written By
CodeGuru Staff
CodeGuru Staff
Nov 21, 1998
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

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)

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.