Problem with Rectangular slide bar on scroll bar of list box

Posted on 1999-01-11
Medium Priority
Last Modified: 2013-11-20
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__;

// CBrowseList

       m_ctlTitle = NULL;



// CBrowseList message handlers

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

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

      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

Question by:AsifMughal
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Expert Comment

ID: 1327500
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.


Author Comment

ID: 1327501
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



Accepted Solution

asker earned 300 total points
ID: 1327502
This is from the on-line help of VC++ 5.0 (but I think it should be avilable in any help or reference on Win32):

GetScrollInfo <Picture> <Picture> <Picture>

The GetScrollInfo function retrieves the parameters of a scroll bar, including the minimum and maximum scrolling positions, the page size, and the position of the scroll box (thumb).

BOOL GetScrollInfo(
HWND hwnd,  // handle of window with scroll bar
int fnBar, // scroll bar flag
LPSCROLLINFO lpsi // pointer to structure for scroll parameters



Identifies a scroll bar control or a window with a standard scroll bar, depending on the value of the fnBar parameter.


Specifies the type of scroll bar for which to retrieve parameters. This parameter can be one of the following values:




Retrieves the parameters for a scroll bar control. The hwnd parameter must be the handle of the scroll bar control.


Retrieves the parameters for the given window's standard horizontal scroll bar.


Retrieves the parameters for the given window's standard vertical scroll bar.


Points to a SCROLLINFO structure whose fMask member, upon entry to the function, specifies the scroll bar parameters to retrieve. Before returning, the function copies the specified parameters to the appropriate members of the structure.

The fMask member can be a combination of the following values:




Copies the scroll page to the nPage member of the SCROLLINFO structure pointed to by lpsi.


Copies the scroll position to the nPos member of the SCROLLINFO structure pointed to by lpsi.


Copies the scroll range to the nMin and nMax members of the SCROLLINFO structure pointed to by lpsi.

Return Values

If the function retrieved any values, the return value is nonzero.

If the function does not retrieve any values, the return value is zero.


The GetScrollInfo function enables applications to use 32-bit scroll positions. Although the messages that indicate scroll-bar position, WM_HSCROLL and WM_VSCROLL, provide only 16 bits of position data, the functions SetScrollInfo and GetScrollInfo provide 32 bits of scroll-bar position data. Thus, an application can call GetScrollInfo while processing either the WM_HSCROLL or WM_VSCROLL messages to obtain 32-bit scroll-bar position data.

The limitation on this technique applies to real-time scrolling of a window’s contents. An application implements real-time scrolling by processing the WM_HSCROLL or WM_VSCROLL messages that carry the SB_THUMBTRACK notification value, thereby tracking the position of the scroll box (thumb) as the user moves it. Unfortunately, there is no function to retrieve the 32-bit position scroll-box position as the user moves the scroll box. Because GetScrollInfo provides only the static position, an application can obtain only 32-bit position data before or after a scroll operation.

See Also



LVM_SCROLL <Picture> <Picture> <Picture>

The LVM_SCROLL message scrolls the content of a list view control. You can send this message explicitly or by using the ListView_Scroll macro.

wParam = (int) dx;  // amount of horizontal scrolling, in pixels or columns
lParam = (int) dy;  // amount of vertical scrolling, in pixels


Integer value that specifies the amount of horizontal scrolling.

If the view type of the list view control is icon view, small icon view, or report view, this value specifies the number of pixels to scroll. If the view type of the list view control is list view, this value specifies the number of columns to scroll.


Integer value that specifies the amount of vertical scrolling.

If the view type of the list view control is icon view, small icon view, or list view, this value specifies the number of pixels to scroll. If the view type of the list view control is report view, this value specifies the number of lines to scroll.

Return Values

Returns TRUE if successful or FALSE otherwise.

See Also



Hope this helps.



Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question