Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Reflectred header control messages in CListCtrl

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Prevent this page from creating additional dialogs. 3 617
has22 challenge 11 105
abstract class with all non abstract mentods 6 80
zeroFront challenge 7 112
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

837 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