🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Setting the Top Item when the ComboBox is dropped down

#3223
From: JD
Date: Fri, 04 Aug 2006 22:47
60 lines
3489 bytes
I'm trying to get my TCheckedComboBox (derived from TComboBox)
to set a specific Top Item when it drops down. I've traced the
problem to the List's subclassed WndProc which I need to
subclass to keep the list from closing as soon as an Item is
clicked so that the user can check multiple items with out
dropping it down for every item (note the 2 lines that have
been commented out):

//--------------------------------------------------------------
void __fastcall TCheckComboBox::ListWndProc( TMessage &Message )
{
    if( Message.Msg == WM_LBUTTONDOWN || Message.Msg == WM_LBUTTONUP )
      {
          TRect R;
          short X = Message.LParamLo, Y = Message.LParamHi;
          ::GetClientRect( FListHandle, &R );
          if( PtInRect(R, Point(X,Y)) )
            {
                if( Message.Msg == WM_LBUTTONDOWN )
                  {
                      FClickedItem = ::SendMessage(FListHandle, LB_GETTOPINDEX, 0, 0) + (Y / ItemHeight);
//                      Message.Result = 0;
//                      return;
                  }
                else
                  {
                      if( FClickedItem == ::SendMessage(FListHandle, LB_GETTOPINDEX, 0, 0) + (Y / ItemHeight) )
                        {
                            Checked[ FClickedItem ] = !Checked[ FClickedItem ];
                            ::SendMessage( FListHandle, LB_GETITEMRECT, FClickedItem, reinterpret_cast<LPARAM>(&R) );
                            ::InvalidateRect( FListHandle, &R, FALSE );
                        }
                      Message.Result = 0;
                      return;
                  }
            }
      }
    Message.Result = ::CallWindowProc( OldListWndProc, FListHandle, Message.Msg, Message.WParam, Message.LParam );
}
//--------------------------------------------------------------

By commenting out the 2 lines, the default behavior of
TComboBox's setting of the top index is enabled but then
there are WM_MOUSEMOVE issues because the object thinks that
the mouse is down which manifest with undesired scrolling and
if I use RelaeseCapture, it causes the list to close.

I've tried every work-around that I can think of from
setting the ItemIndex to setting the top index using
SendMessage (PostMessage too) to send LB_SETTOPINDEX when
I detected the list dropping down and I've come to the
conclusion that the solution (if there is one) is to determine
and implement that one missing thing that the default handler
does when WM_LBUTTONDOWN is processed *or* to determine what I
need to set when the list is dropped down.

Any help please?

~ JD
Technical Details
Message-ID: <44d3ce9c$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,45ced0fb7b84ba0c,start
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "JD" <nospam@nospam.com>
Sender: "JD" <nospam@nospam.com>
Reply-To: "JD" <nospam@nospam.com>
Subject: Setting the Top Item when the ComboBox is dropped down
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 205.188.116.136     
X-Forwarded-For: 172.129.209.229
NNTP-Posting-Host: 207.105.83.66
Message-ID: <44d3ce9c$1@newsgroups.borland.com>
Date: 4 Aug 2006 15:47:56 -0700
X-Trace: newsgroups.borland.com 1154731676 207.105.83.66 (4 Aug 2006 15:47:56 -0700)
Lines: 61
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail