Solved

Reflectred header control messages in CListCtrl

Posted on 1998-12-21
4
538 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

757 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