🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: No Listview custom msg

#9727
From: borland
Date: Mon, 21 Jun 2004 10:31
61 lines
3031 bytes
Thanks a lot...works a treat..

"Remy Lebeau (TeamB)" <gambit47.no.spam@no.spam.yahoo.com> wrote in message
news:40d3fcbd$1@newsgroups.borland.com...
>
> "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: <40d6b8e8$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40d3e14f@newsgroups.borland.com> <40d3fcbd$1@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: "borland" <rogersmail@ntlworld.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <40d3e14f@newsgroups.borland.com> <40d3fcbd$1@newsgroups.borland.com>
Subject: Re: No Listview custom msg
Date: Mon, 21 Jun 2004 11:31:04 +0100
Lines: 63
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2739.300
NNTP-Posting-Host: 81.103.69.122
Message-ID: <40d6b8e8$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1087813864 81.103.69.122 (21 Jun 2004 03:31:04 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail