Solved

Reflectred header control messages in CListCtrl

Posted on 1998-12-21
4
552 Views
Last Modified: 2013-11-20
I created a decendant class of CListCtrl.   When I try to handle and of the HDN_???? reflected messages, I cant.   Is this because they are being handled by CListCtrl, is it an error in MFC message reflection, or am I just expecting too much.

Just a little clarification on the words above, "I cant".   I am not receiving the reflected message, and thus, cant handle it.
0
Comment
Question by:yoffe
  • 3
4 Comments
 
LVL 8

Accepted Solution

by:
Answers2000 earned 50 total points
ID: 1326528
I've had this problem too.  I think the problem is that the header is a child of the list control  (not part of the list control).

Therefore the list control will receive the normal header notifications (not the reflected ones) : HDN_ENDTRACK, not =HDN_ENDTRACK for example.  Basically the class wizard is wrong.

I got around this by overriding OnNotify in my list control class, here's a sample spotting HDN_ENDTRACK from my program (this is from a class deriving from CListCtrl)

BOOL CListContact::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
      HD_NOTIFY *phdn = (HD_NOTIFY *)(lParam) ;// pNMHDR;
      if ( ( phdn->hdr.code ) == HDN_ENDTRACK )
      {
            // call base functionality (do column resize)
            BOOL bReturn = CListCtrl::OnNotify(wParam, lParam, pResult);

            CMailGuruView * pView = (CMailGuruView *)GetParent() ;
            ASSERT_VALID(pView) ;
            pView->OnColumnResize( phdn ) ;

            return bReturn ;
      }

      return CListCtrl::OnNotify(wParam, lParam, pResult);
}

0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1326529
This bit

     CMailGuruView * pView = (CMailGuruView *)GetParent() ;
     ASSERT_VALID(pView) ;
     pView->OnColumnResize( phdn ) ;

Is my code for this message.  Remove it and replace it with your own code
0
 

Author Comment

by:yoffe
ID: 1326530
Thanks 2K.   That was the same assessment that I made of the situation.   I already am handling the message in the OnNotify in my class, just didnt know if possibly I was missing a piece of the puzzle.   BTW, my code was compiled under VC++ 5.0...I assume the header's condition of being a child of the ListCtrl exists under 6.0 as well.

yoffe@flex.net
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1326531
I am using VC5 too.  I remember that it behaves the same in VC4, and would expect the same in VC6

The fact that the header control is a child is why you need to do it this way.  This fact is true for all versions of commctrl.dll I have used/tried - and actually the version of commctrl (not the version of the compiler / MFC) will determine this behaviour.  The only change that might have fixed the class wiz in 6 or later (to use normal notifications for header).  This change wouldn't break existing code.

Strictly speaking the fact the header is a child, probably counts as being "undocumented".  But given changing this will break dozens of Windows app, I expect MS  to leave it that way.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Expand data scrubbing tool 13 32
Complete beginner needs help making a cron job 9 110
Hibernate methods 2 68
scoreUp challenge 14 57
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now