+ nRange1 += (nPageSize - 1);
+ }
+
+ vInfo.cb = sizeof(SBCDATA);
+ vInfo.posFirst = 0;
+ vInfo.posLast = (SHORT)nRange1;
+ vInfo.posThumb = nPos;
+
+ if (nOrient == wxHORIZONTAL )
+ {
+ ulStyle |= SBS_HORZ;
+ if (m_hWndScrollBarHorz == 0L)
+ {
+ //
+ // We create the scrollbars with the desktop so that they are not
+ // registered as child windows of the window in order that child
+ // windows may be scrolled without scrolling the scrollbars themselves!
+ //
+ m_hWndScrollBarHorz = ::WinCreateWindow( hWnd
+ ,WC_SCROLLBAR
+ ,(PSZ)NULL
+ ,ulStyle
+ ,vRect.xLeft
+ ,vRect.yBottom
+ ,vRect.xRight - vRect.xLeft
+ ,20
+ ,hWnd
+ ,HWND_TOP
+ ,FID_HORZSCROLL
+ ,&vInfo
+ ,NULL
+ );
+ }
+ else
+ {
+ RECTL vRect2;
+
+ //
+ // Only want to resize the scrollbar if it changes, otherwise
+ // we'd probably end up in a recursive loop until we crash the call stack
+ // because this method is called in a ScrolledWindow OnSize event and SWP_MOVE | SWP_SIZE
+ // generates those events.
+ //
+ ::WinQueryWindowRect(m_hWndScrollBarHorz, &vRect2);
+ if (!(vRect2.xLeft == vRect.xLeft &&
+ vRect2.xRight == vRect.xRight &&
+ vRect2.yBottom == vRect.yBottom &&
+ vRect2.yTop == vRect.yTop
+ ) )
+ {
+ ::WinSetWindowPos( m_hWndScrollBarHorz
+ ,HWND_TOP
+ ,vRect.xLeft
+ ,vRect.yBottom
+ ,vRect.xRight - vRect.xLeft
+ ,20
+ ,SWP_ACTIVATE | SWP_MOVE | SWP_SIZE | SWP_SHOW
+ );
+ }
+ ::WinSendMsg(m_hWndScrollBarHorz, SBM_SETSCROLLBAR, (MPARAM)nPos, MPFROM2SHORT(0, (SHORT)nRange1));
+ ::WinSendMsg(m_hWndScrollBarHorz, SBM_SETTHUMBSIZE, MPFROM2SHORT((SHORT)nThumbVisible, (SHORT)nRange1), (MPARAM)0);
+ }