Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TListBox with virtual style got wrong index (QC104813)



Permlink Replies: 1 - Last Post: Oct 12, 2016 10:27 AM Last Post By: Remy Lebeau (Te...
Giuseppe Montel...

Posts: 1
Registered: 4/21/99
TListBox with virtual style got wrong index (QC104813)
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 12, 2016 6:48 AM
Hi all,

I need to create a graphic logging system. This work well with TListBox, but when we have problem for huge items as stated in QC104813: during scroll, when index reach 64k limit, goes 0. There is some well known workaround to this bug.

Giuseppe Monteleone
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: TListBox with virtual style got wrong index (QC104813)
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 12, 2016 10:27 AM   in response to: Giuseppe Montel... in response to: Giuseppe Montel...
Giuseppe wrote:

I need to create a graphic logging system. This work well with
TListBox, but when we have problem for huge items as stated in
QC104813: during scroll, when index reach 64k limit, goes 0. There
is some well known workaround to this bug.

The problem only occurs when dragging the scrollbar's thumb. Clicking on
the scrollbar's arrows, or in the empty space surrounding the thumb, does
not exhibit the problem. You will notice that when dragging the thumb, no
matter where you actually drop it, when you release the mouse the thumb jumps
to the actual index being displayed. The reason for this is because the
WM_VSCROLL message is limited to 16-bit positions when issuing SB_THUMBPOSITION
and SB_THUMBTRACK notifications. This is documented on MSDN:

https://msdn.microsoft.com/en-us/library/windows/desktop/bb787577.aspx

Note that the WM_VSCROLL message carries only 16 bits of scroll box position
data. Thus, applications that rely solely on WM_VSCROLL (and WM_HSCROLL)
for scroll position data have a practical maximum position value of 65,535.

However, because the SetScrollInfo, SetScrollPos, SetScrollRange, GetScrollInfo,
GetScrollPos, and GetScrollRange functions support 32-bit scroll bar position
data, there is a way to circumvent the 16-bit barrier of the WM_HSCROLL and
WM_VSCROLL messages. See GetScrollInfo for a description of the technique.

TListBox does not process the WM_VSCROLL message, it is passed as-is to the
underlying ListBox window at the Win32 layer for handling. So the OS, not
the VCL, is wrapping the scrollbar position at 64K when dragging the thumb.
And while it is possible to hook the TListBox to intercept the WM_VSCROLL
message to obtain full 32-bit positions, that does not do anything to help
with visual feedback or drawing of the list items.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02