Catching header messages in a CListView

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

  • Beats by dre primært Er synes er meget godt rimelige

    Posted by rpddbr493 on 07/17/2013 05:17pm

    Udover alle andre hovedtelefoner par, beats Dre lyd præsentation er temmelig god, ikke som “mudrede” og “uklar” støjende lyde, som ofte er problemer med hver hovedtelefon. Nå, denne genre af hovedtelefon er meget godt for den elektroniske, hård rock, og midt tempo hip-hop musik, som helt sikkert kan rock you ingen tvivl om. billige beats by dre er meget til salg i forskellige musik-butikker og du kan købe dem fra enhver stikkontakt til pluk det til din musik dille. Nå, ingen tvivl om, at du kan have en god musik ved at have det, efter alt dette er ‘beats by Dre «og navnet i sig selv er alt for at angive dets kvalitet. Så ven, så hvis du er en af dem, der søger for at have hovedtelefoner til dit musiksystem eller spekulerer at købe det til din iPhone eller iPod, kan du placere din ordre online. Du kan købe denne genre af hovedtelefoner lige fra sidder fra din hjemmecomputer, logge på hjemmesiden at udforske Dre beats rækkevidde at smage essensen af musikken. [url=http://kbhretelefonerbillig.webstarts.com/]beats by dre studio[/url] IOC og LOCOG ikke havde reageret på en anmodning om at kommentere på tidspunktet for offentliggørelsen. Den officielle sponsor, der er mest tilbøjelige til at føle sig mest forurettede ved stunt er Panasonic.England fodboldspillere brugte Dr. Dre hovedtelefoner ved Euro 2012 for at undgå pressen. Hovedtelefonerne voksede i popularitet på Beijing 2008 Olympiske Lege, efter at selskabet gav dem til basketball stjerne LeBron James, og han gav dem ud til medlemmer af Team USA.Den baghold markedsføring initiativet kommer i hælene på en protest – iværksat af amerikanske sportsfolk, herunder 400m løber Sanya Richards-Ross – kritisere regel 40 i IOC adfærdskodeks. Reglen forbyder atleter fra at nævne deres personlige sponsorer på sociale medier under legene. [url=http://nyebeatsbydrdre.bloguedobebe.com/]beats by dre[/url] BIII booo din troede involverer let jazz, med essentials involverer normal, god ole ‘, sammen med digitalkameraer sange for dig at lave en ny specifikt eksklusiv lyd. BIII øjeblikket omdefinerer private musik ekspertise til at gøre dine musikernes øretelefoner. Enhver observere, hver eneste nuance, kan optaget med aldrig-hørt-før realistisk look, plus iøjnefaldende design og stil trådløse høretelefoner bestemt ved en ny trompet mundstykke har som en installation vidnesbyrd om den mestre kunsten. Disse former for sædvanligvis er ikke kun de bedste ørepuder vedrørende jazz. Uanset hvad nogen hører, vil BIII sikkert vokset til betragtes som en af dine nuværende all-time musikalske teknologi højder.

    Reply
  • All top calibre by Dr Dre Headphones

    Posted by motherdhmm on 06/04/2013 10:00pm

    [url=http://www.headphonescheaponlineaustralia.com/products_all.html]Beats headphones shop[/url] According to official text, monster beats close dr .dre unaccompanied Headphones blackWire Monster 4 the winding Quadripole grant technology, to decry look like transmission erosion, and to bring off the highest value signal articulate balance, lucidity and resolution. In uniting to the second to none in harmony shape of the appearance, the headset in terms of functionality, there are myriad characteristic design. Leading, what is surprising is that the headset with built-in muting limit intrigue can be said is an active headset. [url=http://www.headphonescheaponlineaustralia.com/products_all.html]Beats headphones shop[/url] Small number dr dre beats, in your speak they can mature a crushing, if too leak-proof ear cup headphones.Noise-canceling Monster Beats are by worn exchange for some time longer,according in the service of your aeroplane time.To another deliver, if they are too unsecured,you most tenable to fortify them every period you farther down your chair! Prune trait coordinated to dr dre beats includes this sui generis top-notch quality look people uncover,that all but all all of us will-power most likely desire together with show. [url=http://www.headphonescheaponlineaustralia.com/]dr dre beats[/url] Giant Beats Solitary HD Apex Definition headphones, The advanced proprietary titanium coated driver technology provides ultra careful highs and mids, increased by dark, distortion-free bass, so you hear every technicalities, the way the artist intended you to hear it. At the gym, going for a consort with a trace, reiterative traveler, or by a hair's breadth cruising down the street, Beats Solo HD are the supreme unveil substance headphone. Monster¡¯s firm tri-fold work makes it easy to co-op give credence to in bags, suitcases, and jackets. Supplementary, the ultra inferior portrait right bend connector hugs your music speculator and is ideal representing airplane headquarters jacks.

    Reply
  • Why OnBeginTrack can't work

    Posted by Legacy on 06/14/2001 12:00am

    Originally posted by: Bob

    Great idea. But after I add OnBeginTrack and OnEndTrack as below:
    void 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!

    Reply
  • Message from several pushbuttons -- how to process?

    Posted by Legacy on 02/18/2000 12:00am

    Originally posted by: ME

    Please,can anyone tell how to handle a message
    
    from several pushbuttons, which are created dynamically
    with a "Create" member function of CButton class.
    The matter is the buttons have contiguous IDs
    (i.e. 10000,10001 etc) and when are clicked, this event should be handled. I've tried
    a ON_NOTIFY_RANGE(NM_CLICK,10000,10001,OnClick) but
    a handling function OnClick malfunctioned(handling
    function should take buttons' IDs -- directly or
    through NMHDR structure).
    So how to process this message ?

    Thanking you in advance!

    Eugene V. Sharavin (evgeny@sibron.ru)

    Reply
  • Unexpected UNICODE Notification Messages.Could be an Official NT Bug

    Posted by Legacy on 12/19/1999 12:00am

    Originally 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.

    Reply
  • Suggested solution to NT CListCtrl-CHeaderCtrl 'feature'

    Posted by Legacy on 12/03/1999 12:00am

    Originally posted by: Richard Hazlewood

    Here's a snippet of code I use in my CListCtrl class which:
    
    

    1) Allows the use of ClassWizard's HDN_ notifications by routing them back through notification reflection,

    2) Fixes the NT header control sizing problem, when running the header control in ANSI mode (see previous comment)
    (HDN_ITEMCHANGING updates the scroll bar, HDN_ITEMCHANGED updates the list control)

    ///////////////////////////////////////////////////////

    #include <..\src\afximpl.h> //for afxData

    BOOL CAListCtrl::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
    {
    //Note: even though the class wizard shows HDN_ reflect notifications
    // for CListCtrls, they don't actually work because they are really notifying
    // the child header control. This solves the problem by forcing a reflection.

    NMHDR *pNMHDR = (NMHDR*)lParam;
    CHeaderCtrl *pHeader = GetHeaderCtrl();
    if (pHeader && (pNMHDR->hwndFrom == pHeader->m_hWnd)) {
    BOOL bReflect = FALSE;
    switch (pNMHDR->code) {
    //we could route every NM_ notification here, but I only require specific items:
    case NM_RCLICK: //because HDN_ITEMCLICK only sends left button..
    bReflect = TRUE;
    break;
    case HDN_ITEMCHANGINGA:
    if (afxData.bWin95)
    break;
    //list-control bug: on NT it doesn't seem to have handlers
    // for HDN_ITEMCHANGING/HDN_ITEMCHANGED Ansi versions when
    // the header is set to Ansi mode
    pNMHDR->code = HDN_ITEMCHANGINGW; //for scrollbar update
    *pResult = SendMessage(WM_NOTIFY, wParam, (LPARAM)pNMHDR);
    return TRUE;
    case HDN_ITEMCHANGEDA:
    if (afxData.bWin95)
    break;
    pNMHDR->code = HDN_ITEMCHANGEDW; //for column update
    *pResult = SendMessage(WM_NOTIFY, wParam, (LPARAM)pNMHDR);
    return TRUE;
    default:
    ASSERT(HDN_FIRST > HDN_LAST); //numbering is backwards
    bReflect = ((pNMHDR->code >= HDN_LAST) && (pNMHDR->code <= HDN_FIRST));
    break;
    }
    if (bReflect && ReflectChildNotify(WM_NOTIFY, wParam, lParam, pResult))
    return TRUE;
    }
    return CListCtrl::OnNotify(wParam, lParam, pResult);
    }

    Reply
  • HDN_ENDTRACK and GetColumnWidth in WinNt vs. Win95

    Posted by Legacy on 08/26/1999 12:00am

    Originally posted by: Dieter Elbracht

    your suggestions work fine so far.

    A user changes the width of a Column.
    GetColumnWidth in WinNt gives the new ColumWidth
    where in Win95 it always gives the width before the change

    Reply
  • Another suggestion

    Posted by Legacy on 08/25/1999 12:00am

    Originally posted by: Steven Boswell

    In the parent dialog's OnInitDialog(), get a pointer to the CListCtrl object (call it pList), and then
    
    

    pList->GetHeaderCtrl()->SetDlgCtrlID(pList->GetDlgCtrlID());

    Then all the macros that ClassWizard generates, such as

    ON_NOTIFY(HDN_ENDTRACK, IDC_LIST1, OnEndTrack)

    will work fine.

    Reply
  • UNCODE messages are always sent!

    Posted by Legacy on 02/25/1999 12:00am

    Originally 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)

    Reply
  • My suggestion

    Posted by Legacy on 02/03/1999 12:00am

    Originally 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
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • Hundreds of millions of users have adopted public cloud storage solutions to satisfy their Private Online File Sharing and Collaboration (OFS) needs. With new headlines on cloud privacy issues appearing almost daily, the need to explore private alternatives has never been stronger. Join ESG Senior Analyst Terri McClure and Connected Data in this on-demand webinar to take a look at the business drivers behind OFS adoption, how organizations can benefit from on-premise deployments, and emerging private OFS …

Most Popular Programming Stories

More for Developers

RSS Feeds