Discussion:
Scrolling whole lines only
(too old to reply)
int21h
2011-11-27 17:12:15 UTC
Permalink
In an editor-like application I want only whole lines being displayed.
Basically this works as I chose font size 12 and use the following
values for SetScrollSizes

SetScrollSizes(MM_TEXT, CSize(630, 16 * pDoc->m_dwLines),
CSize(630, 16 * countLines), // countLines lines in client rect
visible
CSize(630, 16)); // a line will move 16 units

Unfortunately this does not work for moving the slider with the mouse.
With this method it still is
possible to move the lines so that lines are partially (e.g. lower 4
pixels) displayed in the 1st line.

I tried to work around this by overriding OnVScroll (snippet):

::GetScrollInfo(m_hWnd, SB_VERT, &info);
nPos = info.nTrackPos;
nPos &= 0xfffffff0; // slider now only will give back "whole"
lines

But now I run into the problem that the slider (sometimes) cannot be
moved to the end position
(because of the cutting away with 0xff ff ff f0). This also depends on
the size of the client rect.

Do you have any idea how to implement this?
ScottMcP [MVP]
2011-11-27 19:31:48 UTC
Permalink
Instead of calling the base class OnVScroll you can do it yourself by
calling ScrollToPosition. Check the CScrollView::OnVScroll source code
to see what else you have to do.

Loading...