🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #9723

Re: No Listview custom msg

#9723
From: Remy Lebeau (TeamB)
Date: Sat, 19 Jun 2004 08:39
52 lines
2822 bytes
"borland" <rogersmail@ntlworld.com> wrote in message
news:40d3e14f@newsgroups.borland.com...

> the only difference between the two programs is the listview
> that works fine is placed upon a form directly, whereas this
> one that i am having trouble with is place upon a TabSheet
> which in turn is on a PageControl.

That makes a *big* difference.  You are trying to catch the message in the
wrong place.  The Parent of the ListView is the one that always receives the
message.  In this case, the TabSheet, not the form, will be the one to
receive the message.  Since you are trying to catch it from the form itself,
you will never see the message when the ListView is on the TabSheet.

With that said, you should subclass the ListView's WindowProc property
directly and then look for CN_NOTIFY messages instead of WM_NOTIFY.  The VCL
is specifically set up to forward WM_NOTIFY and WM_COMMAND messages to
individual components so that they can handle their own messages directly
regardless of which Parent components received the original messages.

In other words, do the following instead:

    TWndMethod OldListViewProc = NULL;

    __fastcall TMainForm::TMainForm(TComponent *Owner)
        : TForm(Owner)
    {
        OldListViewProc = ListView1->WindowProc;
        ListView1->WindowProc = ListViewWndProc;
    }

    void __fastcall TMainForm::ListViewWndProc(TMessage &Message)
    {
        if( Message.Msg == CN_NOTIFY )
        {
            LPNM_LISTVIEW lpnm = (NM_LISTVIEW *)Message.LParam;
            if( lpnm->hdr.code == NM_CUSTOMDRAW )
            {
                // at this point, you already know the message belongs
                // to the ListView so just always handle it here as
needed...
                return;
            }
        }

        // default handling...
        OldListViewProc(Message);
    }


Gambit
Technical Details
Message-ID: <40d3fcbd$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!irazu.switch.ch!switch.ch!news.belwue.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40d3e14f@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,bcfae62bc6939384
X-Google-Attributes: gid10cc67,public
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <40d3e14f@newsgroups.borland.com>
Subject: Re: No Listview custom msg
Date: Sat, 19 Jun 2004 01:39:36 -0700
Lines: 54
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.169.168.124
Message-ID: <40d3fcbd$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1087634621 68.169.168.124 (19 Jun 2004 01:43:41 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!irazu.switch.ch!switch.ch!news.belwue.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail