🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

listview redraw problem

#10607
From: freeman
Date: Wed, 31 Mar 2004 06:37
102 lines
4749 bytes
I am currently using the below WMNotify code to custom draw the rows in a
listview (vsReport style)with specific colors:
This all works fine for modifying the colors etc and works well,but i added
the move captionless form code below which moves the form fine , but if i
use it to move the form, then to use the horizontal scroll bar i have to do
something like sendmessage to maximize or restore the form before it will
allow me to use the scrollbar.. the vertical scroll bar seems to work ok
though, even after moving the form..
It seems if i take note where i moved the form from, and
place the form back to that position then the scroll bar picks up the move
is over it and allows me to use the horiz scoll..so it seems that when i
move the form and click on the scroll bar the app thinks i am over the
listview and not the scrollbar.Any help...?

///// Move captionless form code  ////
if (Button == mbLeft)
{
ReleaseCapture();
SendMessage(Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
}


//////Custom draw my listview  routine/////
void __fastcall TItemsFoundForm::WMNotify(TMessage &Msg)
{
    LPNM_LISTVIEW lpnm = (NM_LISTVIEW *)Msg.LParam;

    // see if the message is a Custom Draw message
    if (lpnm->hdr.code == NM_CUSTOMDRAW)
    {
        // see if the message is from the ListView
        if (lpnm->hdr.hwndFrom == ListView1->Handle)
        {
            LPNMLVCUSTOMDRAW lplvcd = (NMLVCUSTOMDRAW *)Msg.LParam;
            switch(lplvcd->nmcd.dwDrawStage)
            {
                // prior to painting the items...
                case CDDS_PREPAINT:
                {
                    Msg.Result = CDRF_NOTIFYITEMDRAW;
                    return;
                }
                case CDDS_ITEMPREPAINT:
                {
                    // tell Windows we want notification of
                    // each subitem being drawn

                    Msg.Result = CDRF_NOTIFYSUBITEMDRAW;
                    return;
                }
                case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
                {
                    // index of current Item (row) being drawn
                    int ItemIndex = lplvcd->nmcd.dwItemSpec;

      switch (lplvcd->iSubItem)
                    {
                     // first column (not really a subitem)
                     case 0:
                     {

if(!ListView1->Items->Item[ItemIndex]->SubItems->Strings[1].Pos("0") &&
!ListView1->Items->Item[ItemIndex]->SubItems->Strings[7].Pos("Day"))
                              {
                              lplvcd->clrText = ColorToRGB(clRed);
                              lplvcd->clrTextBk =
ColorToRGB((TColor)0x00C6FB8C);
                              }
                            else

if(!ListView1->Items->Item[ItemIndex]->SubItems->Strings[1].Pos("0"))
                            {
                            lplvcd->clrText = ColorToRGB(clNavy);
                            lplvcd->clrTextBk =
ColorToRGB((TColor)0x00A4E3FF);
                            }
                            else

if(!ListView1->Items->Item[ItemIndex]->SubItems->Strings[7].Pos("Day"))
                            {
                            lplvcd->clrText = ColorToRGB(clWhite);
                            lplvcd->clrTextBk =
ColorToRGB((TColor)0x008284FF);
                            }
                            else{
                             lplvcd->clrText = ColorToRGB(clNavy);
                             lplvcd->clrTextBk =
ColorToRGB(clInactiveCaption);
                               }

                      break;
                      }
                   }
                    Msg.Result = CDRF_NEWFONT;
                    return;
                }
                 default: Msg.Result = CDRF_DODEFAULT;
            }
        }
    } else TForm::Dispatch(&Msg);

}
Technical Details
Message-ID: <406a670b$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.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

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,7897366892743d08,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-03-30 22:39:44 PST
From: "freeman" <rogersmail@ntlworld.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: listview redraw problem
Date: Wed, 31 Mar 2004 07:37:03 +0100
Lines: 106
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 81.103.70.228
Message-ID: <406a670b$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1080715019 81.103.70.228 (30 Mar 2004 22:36:59 -0800)
Path: arc1-ca.pugleaf.net!archiver1.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