🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
2 messages
2 total messages Started by JD Fri, 04 Aug 2006 22:47
Setting the Top Item when the ComboBox is dropped down
#3223
Author: 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
Re: Setting the Top Item when the ComboBox is dropped down
#3236
Author: JD
Date: Mon, 07 Aug 2006 08:55
15 lines
1113 bytes
"JD" <nospam@nospam.com> wrote:
>

Using WinSight I found that there were 2 messages being
processed by the object that I couldn't identify (exactly
how they were reported):

    WM_USER + 0xB933
and
    WM_0x2A3

Any ideas?

~ JD
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads