Solved

Reflectred header control messages in CListCtrl

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
repeatEnd java challenge 42 85
substring method in java 1 135
format the code in java 6 109
Change to event 1 126
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 …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

679 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