richedit: Scrollinfo stored as 16-bit values externally.

The application Blitzin2 was sending WM_VSCROLL messages to the
richedit control directly, when normally this message is supposed to
be a notification sent after the scrollinfo is set.  Native richedit
controls always use the 16-bit value passed to this message to set the
scroll position for SB_THUMBPOSITION, rather than trying to find a
32-bit value through GetScrollInfo like I had previously done.
This commit is contained in:
Dylan Smith 2009-07-21 21:06:00 -04:00 committed by Alexandre Julliard
parent e5f4c802dc
commit 0deb3d04ed
2 changed files with 31 additions and 20 deletions

View File

@ -3587,6 +3587,11 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
POINT *point = (POINT *)lParam;
point->x = editor->horz_si.nPos;
point->y = editor->vert_si.nPos;
/* 16-bit scaled value is returned as stored in scrollinfo */
if (editor->horz_si.nMax > 0xffff)
point->x = MulDiv(point->x, 0xffff, editor->horz_si.nMax);
if (editor->vert_si.nMax > 0xffff)
point->y = MulDiv(point->y, 0xffff, editor->vert_si.nMax);
return 1;
}
case EM_GETTEXTRANGE:
@ -4012,15 +4017,10 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
case SB_THUMBTRACK:
case SB_THUMBPOSITION:
{
SCROLLINFO sbi;
sbi.cbSize = sizeof(sbi);
sbi.fMask = SIF_TRACKPOS;
/* Try to get 32-bit track position value. */
if (!GetScrollInfo(editor->hWnd, SB_HORZ, &sbi))
/* GetScrollInfo failed, settle for 16-bit value in wParam. */
sbi.nTrackPos = HIWORD(wParam);
ME_HScrollAbs(editor, sbi.nTrackPos);
int pos = HIWORD(wParam);
if (editor->horz_si.nMax > 0xffff)
pos = MulDiv(pos, editor->horz_si.nMax, 0xffff);
ME_HScrollAbs(editor, pos);
break;
}
}
@ -4064,15 +4064,10 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
case SB_THUMBTRACK:
case SB_THUMBPOSITION:
{
SCROLLINFO sbi;
sbi.cbSize = sizeof(sbi);
sbi.fMask = SIF_TRACKPOS;
/* Try to get 32-bit track position value. */
if (!GetScrollInfo(editor->hWnd, SB_VERT, &sbi))
/* GetScrollInfo failed, settle for 16-bit value in wParam. */
sbi.nTrackPos = HIWORD(wParam);
ME_VScrollAbs(editor, sbi.nTrackPos);
int pos = HIWORD(wParam);
if (editor->vert_si.nMax > 0xffff)
pos = MulDiv(pos, editor->vert_si.nMax, 0xffff);
ME_VScrollAbs(editor, pos);
break;
}
}

View File

@ -1036,17 +1036,21 @@ void ME_ScrollAbs(ME_TextEditor *editor, int x, int y)
if (editor->horz_si.nPos != x) {
x = min(x, editor->horz_si.nMax);
x = max(x, editor->horz_si.nMin);
ITextHost_TxSetScrollPos(editor->texthost, SB_HORZ, x, TRUE);
scrollX = editor->horz_si.nPos - x;
editor->horz_si.nPos = x;
if (editor->horz_si.nMax > 0xFFFF) /* scale to 16-bit value */
x = MulDiv(x, 0xFFFF, editor->horz_si.nMax);
ITextHost_TxSetScrollPos(editor->texthost, SB_HORZ, x, TRUE);
}
if (editor->vert_si.nPos != y) {
y = min(y, editor->vert_si.nMax - (int)editor->vert_si.nPage);
y = max(y, editor->vert_si.nMin);
ITextHost_TxSetScrollPos(editor->texthost, SB_VERT, y, TRUE);
scrollY = editor->vert_si.nPos - y;
editor->vert_si.nPos = y;
if (editor->vert_si.nMax > 0xFFFF) /* scale to 16-bit value */
y = MulDiv(y, 0xFFFF, editor->vert_si.nMax);
ITextHost_TxSetScrollPos(editor->texthost, SB_VERT, y, TRUE);
}
if (abs(scrollX) > editor->sizeWindow.cx ||
@ -1170,6 +1174,12 @@ void ME_UpdateScrollBar(ME_TextEditor *editor)
if ((bScrollBarWillBeVisible || bScrollBarWasVisible) &&
editor->styleFlags & WS_HSCROLL)
{
if (si.nMax > 0xFFFF)
{
/* Native scales the scrollbar info to 16-bit external values. */
si.nPos = MulDiv(si.nPos, 0xFFFF, si.nMax);
si.nMax = 0xFFFF;
}
if (editor->hWnd) {
SetScrollInfo(editor->hWnd, SB_HORZ, &si, TRUE);
} else {
@ -1219,6 +1229,12 @@ void ME_UpdateScrollBar(ME_TextEditor *editor)
if ((bScrollBarWillBeVisible || bScrollBarWasVisible) &&
editor->styleFlags & WS_VSCROLL)
{
if (si.nMax > 0xFFFF)
{
/* Native scales the scrollbar info to 16-bit external values. */
si.nPos = MulDiv(si.nPos, 0xFFFF, si.nMax);
si.nMax = 0xFFFF;
}
if (editor->hWnd) {
SetScrollInfo(editor->hWnd, SB_VERT, &si, TRUE);
} else {