Problem with Rectangular slide bar on scroll bar of list box

Posted on 1999-01-11
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
  • 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 100 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 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