Link to home
Start Free TrialLog in
Avatar of AsifMughal
AsifMughal

asked on

Problem with Rectangular slide bar on scroll bar of list box

hello All

I have two List Boxes of type ClistBox.  One of the listboxes is just for titles while the other contains the data and a horizontal scroll bar.  I am trying to move the titles in the title listbox when the user clicks onto the scroll bar of the data listbox. The horizontal scroll bar is working when the user clicks on the arrow of the scroll bar but DOES NOT work when the user click drags the rectangular slide bar on the scroll bar.  The code is as follows:

CListBox            m_ctlTitleList;
CBrowseList            m_ctlPatientList;

The CbrowseList class code is as follows:

// brwslist.cpp : implementation file
//

#include "StdAfx.h"
#include "Patient.h"
#include "BrwsList.h"

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CBrowseList

CBrowseList::CBrowseList()
{
       m_ctlTitle = NULL;
}

CBrowseList::~CBrowseList()
{
}


BEGIN_MESSAGE_MAP(CBrowseList, CListBox)
      //{{AFX_MSG_MAP(CBrowseList)
      ON_WM_HSCROLL()
      //}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CBrowseList message handlers

void CBrowseList::SetTitle( CListBox* aControl )
{
      m_ctlTitle = aControl;
}

void CBrowseList::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
      /*if (nSBCode == SB_THUMBTRACK)
            return;*/

      if (m_ctlTitle)                   
            if ((nSBCode == SB_THUMBPOSITION) || (nSBCode == SB_THUMBTRACK)) {
                  m_ctlTitle->SetScrollPos( SB_HORZ, nPos, TRUE );
            } else
                  m_ctlTitle->SendMessage( WM_HSCROLL, MAKEWORD(nSBCode, nPos), NULL);
            
/*      if ((nSBCode == SB_THUMBTRACK) || (nSBCode == SB_ENDSCROLL))
            return;            // eat it
  */
      CListBox::OnHScroll(nSBCode, nPos, pScrollBar);
}

I look forward to a reply.

Best Regards


Asif
Avatar of asker
asker

When the ListControl receives a THUMBTRACK or THUMBPOSITION, it does not use their parameters (track position). Instead it calls GetScrollInfo with the flag set to TRACKPOS. In your case, the track pos of the real scroll bar for the second list is unchanged - that is why it does not scrolls even when receiving WM_*SCROLL messages.

You should use LVM_SCROLL messages.

Regards,
Asker.
Avatar of AsifMughal

ASKER

Thanks for your reply.  I can't find any information on the GetScrollInfo and on the LVM_SCROLL message in any of the reference books. I would be grateful if you could send me some sample code or recommend any articles.

Thanks in advance

Asif

ASKER CERTIFIED SOLUTION
Avatar of asker
asker

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial