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)
Comments
Why OnBeginTrack can't work
Posted by Legacy on 06/14/2001 12:00amOriginally posted by: Bob
Great idea. But after I add OnBeginTrack and OnEndTrack as below:
Replyvoid CListDlg::OnEndTrack(NMHDR* pNMHDR, LRESULT* pResult)
{
HD_NOTIFY *phdn = (HD_NOTIFY *) pNMHDR;
// TODO: Add your control notification handler code here
*pResult = 0;
}
and
void CListDlg::OnBegintrackList1(NMHDR* pNMHDR, LRESULT* pResult)
{
HD_NOTIFY *phdn = (HD_NOTIFY *) pNMHDR;
// TODO: Add your control notification handler code here
*pResult = 0;
}
Then, add the prototype in class declare as below:
afx_msg void OnBeginTrack(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnEndTrack(NMHDR* pNMHDR, LRESULT* pResult);
But when I debug the code, resize the column's width, I find that OnEndTrack works fine but OnBeginTrack does NOT work at all.
Why? Can anybody give me some advise?
Many thanks!
Message from several pushbuttons -- how to process?
Posted by Legacy on 02/18/2000 12:00amOriginally posted by: ME
ReplyUnexpected UNICODE Notification Messages.Could be an Official NT Bug
Posted by Legacy on 12/19/1999 12:00amOriginally posted by: Sam Hobbs
There is a documented bug in NT. See Microsoft Knowledge Base Article Q148533, "PRB: No ANSI Notifications from Control Created in OnCreate". I think it explains the problems with getting unexpected UNICODE notification messages.
However, when I implement the solution described in that article and I add processing for a HDN_ENDTRACK reflected message, I get the problem that (under NT only) the columns of the list control do not re-size as they should when I drag a column guide.
ReplySuggested solution to NT CListCtrl-CHeaderCtrl 'feature'
Posted by Legacy on 12/03/1999 12:00amOriginally posted by: Richard Hazlewood
ReplyHDN_ENDTRACK and GetColumnWidth in WinNt vs. Win95
Posted by Legacy on 08/26/1999 12:00amOriginally posted by: Dieter Elbracht
your suggestions work fine so far.
A user changes the width of a Column.
ReplyGetColumnWidth in WinNt gives the new ColumWidth
where in Win95 it always gives the width before the change
Another suggestion
Posted by Legacy on 08/25/1999 12:00amOriginally posted by: Steven Boswell
ReplyUNCODE messages are always sent!
Posted by Legacy on 02/25/1999 12:00amOriginally posted by: Stuart Baker
It would appear that on my machine (NT4 Sp3) that for the Header control notification messages (HDN_xxxx) they are all sent as HDN_xxxW, that is to say the unicode versions, why? I dont know!
Guess someone at MS screwed up some how...if you spy++ on explorer4's header ctrl that too receives unicode messages (no that the proves much though...I didn't try it on any other windows)
ReplyMy suggestion
Posted by Legacy on 02/03/1999 12:00amOriginally posted by: Gopalakrishna Pillai.K
We have to add macros for both widecharacter and unicode.So please add
two macros for each message like this and check which one is working
ON_NOTIFY(HDN_BEGINTRACKW, 0, OnBeginTrack)
ON_NOTIFY(HDN_BEGINTRACKA, 0, OnBeginTrack)
Reply