Google Groepen ondersteunt geen nieuwe Usenet-berichten of -abonnementen meer. Historische content blijft zichtbaar.

Scroll bar size not supports values bigger than 32767?

288 weergaven
Naar het eerste ongelezen bericht

nadav cohen

ongelezen,
3 apr 2003, 01:06:4603-04-2003
aan
Hi,

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.

david m-

ongelezen,
3 apr 2003, 01:26:4003-04-2003
aan
"nadav cohen" <na...@siglab.technion.ac.il> wrote in message
news:78bf64c9.03040...@posting.google.com...

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.


James Brown

ongelezen,
3 apr 2003, 03:23:3803-04-2003
aan
Correction:
All 32bit versions of Windows (this includes Win9x and WinNT versions)
support 32bit scrollbar values.

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...

nadav cohen

ongelezen,
3 apr 2003, 06:48:5303-04-2003
aan
"david m-" <utc.4e...@ntlworld.com> wrote in message news:<wrQia.524$Ok4...@newsfep1-gui.server.ntli.net>...

O.K.!!
Thanks a lot,

Nadav.

Jean-Claude Garreau

ongelezen,
4 apr 2003, 11:06:5304-04-2003
aan
Yes, thats true. I had the same problem, and the only solution I found
was to...
redesign my view window!!!

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...

Scott McPhillips

ongelezen,
5 apr 2003, 21:21:5905-04-2003
aan
Jean-Claude Garreau wrote:
>
> Yes, thats true. I had the same problem, and the only solution I found
> was to...
> redesign my view window!!!
>
> If you find another solution, I'm interested.
>
> Jean Claude
>

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]

Colin Wray

ongelezen,
6 feb 2024, 10:21:376 feb
aan
Worked like magic for me, although this page in Firefox appears to be failing to scroll to the bottom,
and MS Visual Studio 2022 Class Wizard doesn't work at all so had to use 2019.

0 nieuwe berichten