My program uses CScrollView class for viewing an audio signal, and
allows the user to zoom in on the signal, and scroll through it using
the scroll bar. The problem is that when the user clicks on the scroll
mark and drags it to a different scroll position, the scroll (and the
scroll mark) jumps to the start of the scroll (or near the start),
instead of to the desired position. I've managed to figure out that
this happens when my scroll's total size is bigger than 32767, and
this is despite the fact that the OnHScroll function uses UINT, which
should support up to 4000000000.
Does anyone know what can I do in this case?
tnx,
Nadav.
Win9x only supports 16bit scroll sizes.
WinNT and upwards supports 32bit scroll sizes.
However there seems to be a problem in MFC in handling them as its the 16
bit scroll position which gets processed.
So you see the jump back to the start when you scroll past 32767.
You can fix this by inheriting from CScrollView overriding On?Scroll and
replacing the 16bit position with the 32 bit one.
Snippet of code below works in spite of what Microsoft say in their
description of OnVScroll.
// The MFC CScrollView::OnVScroll() fails to use the 32bit thumb position
// This override corrects that by getting the thumb position from
GetScrollInfo()
void CScrollView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
if (nSBCode == SB_THUMBTRACK)
{
SCROLLINFO lpScrollInfo;
GetScrollInfo(SB_VERT, &lpScrollInfo);
nPos = lpScrollInfo.nTrackPos;
TRACE("nPos = %d, nTrackPos %d\n", lpScrollInfo.nPos,
lpScrollInfo.nTrackPos);
}
CScrollView::OnVScroll(nSBCode, nPos, pScrollBar);
}
and similarly for OnHScroll.
Note that this is only applicable to WinNT upwards as Win9x doesn't support
it full stop.
david m.
Simply use SetScrollInfo instead of the (backwardly compatible 16bit
SetScrollPos)
and you can do this with no problems..
James
--
www.catch22.uk.net
Free Win32 Software, Source Code and Tutorials
"david m-" <utc.4e...@ntlworld.com> wrote in message
news:wrQia.524$Ok4...@newsfep1-gui.server.ntli.net...
O.K.!!
Thanks a lot,
Nadav.
If you find another solution, I'm interested.
Jean Claude
PS: I dont think UINT ranges up to 4000000000 (it is an unsigned int, not an
unsigned long). But it should range at least
to 2*32767
"nadav cohen" <na...@siglab.technion.ac.il> a écrit dans le message de news:
78bf64c9.03040...@posting.google.com...
This gives you the full 32 bits of scroll bar range...
void CGScrollView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar*
pScrollBar)
{
if(nSBCode == SB_THUMBTRACK || nSBCode == SB_THUMBPOSITION)
{
// User is dragging the scroll bar.
// nPos is a legacy 16 bit coordinate.
// Replace it with 32-bit position (ref: Q166473)
SCROLLINFO si;
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_TRACKPOS;
GetScrollInfo(SB_HORZ, &si);
nPos = si.nTrackPos;
}
CScrollView::OnHScroll(nSBCode, nPos, pScrollBar);
}
--
Scott McPhillips [VC++ MVP]