Microsoft KB Archive/197411

{|
 * width="100%"|

BUG: Scrollbar Notifications Report Incorrect Position

 * }

Q197411

-

The information in this article applies to:


 * Microsoft Windows CE

-

SYMPTOMS
The scroll position may be reported incorrectly when SB_THUMBPOSITION and SB_THUMBTRACK scroll notifications are received.

CAUSE
Windows CE maps the scroll position into the range 0 - (nMax - nMin) where 0 is the minimum scroll position and (nMax - nMin) is the maximum scroll position. nMin and nMax are the minimum and maximum scroll positions set by calling SetScrollRange or SetScrollInfo.

RESOLUTION
When handling SB_THUMBPOSITION and SB_THUMBTRACK notifications, add the minimum scroll position to the position reported in the WM_HSCROLL or WM_VSCROLL message (nPos) to obtain the actual position.

Sample Code
  case WM_VSCROLL: {     int nScrollCode = (int)LOWORD(wParam); int nPos = (short int)HIWORD(wParam);

SCROLLINFO si = {sizeof(SCROLLINFO), SIF_PAGE|SIF_POS|SIF_RANGE|SIF_TRACKPOS, 0, 0, 0, 0, 0};     GetScrollInfo (hWnd, SB_VERT, &si);

int nNewPos = si.nPos;

switch (nScrollCode) {        [ ... ]

case SB_THUMBPOSITION: nNewPos = nPos + si.nMin; // Adding si.nMin here // is the workaround. break; }

si.fMask = SIF_POS; si.nPos = nNewPos; SetScrollInfo (hWnd, SB_VERT, &si, TRUE); return TRUE; }

STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

Additional query words:

Keywords : kbcode kbCtrl kbSDKPlatform kbGrpDSUser kbOSWinCE100bug kbOSWinCE200bug kbOSWinCE210bug

Issue type : kbbug

Technology : kbWinCESearch