Beispiel #1
0
void ScrollTo(HWND hwnd, struct ClcData *dat, int desty, int noSmooth)
{
	DWORD startTick, nowTick;
	int oldy = dat->yScroll;
	RECT clRect, rcInvalidate;
	int maxy, previousy;

	if (dat->iHotTrack != -1 && dat->yScroll != desty) {
		pcli->pfnInvalidateItem(hwnd, dat, dat->iHotTrack);
		dat->iHotTrack = -1;
		ReleaseCapture();
	}
	GetClientRect(hwnd, &clRect);
	rcInvalidate = clRect;

	maxy = RowHeight::getTotalHeight(dat)-clRect.bottom;
	if (desty > maxy)
		desty = maxy;
	if (desty < 0)
		desty = 0;
	if (abs(desty - dat->yScroll) < 4)
		noSmooth = 1;
	if ( !noSmooth && dat->exStyle & CLS_EX_NOSMOOTHSCROLLING)
		noSmooth = 1;
	previousy = dat->yScroll;
	if ( !noSmooth) {
		startTick = GetTickCount();
		for (; ;) {
			nowTick = GetTickCount();
			if (nowTick >= startTick + dat->scrollTime)
				break;
			dat->yScroll = oldy + (desty - oldy) * (int) (nowTick - startTick) / dat->scrollTime;
			if (dat->backgroundBmpUse & CLBF_SCROLL || dat->hBmpBackground == NULL)
				ScrollWindowEx(hwnd, 0, previousy - dat->yScroll, NULL, NULL, NULL, NULL, SW_INVALIDATE);
			else
				InvalidateRect(hwnd, NULL, FALSE);
			previousy = dat->yScroll;
			if (cfg::dat.bSkinnedScrollbar && !dat->bisEmbedded)
				CoolSB_SetScrollPos(hwnd, SB_VERT, dat->yScroll, TRUE);
			else
				SetScrollPos(hwnd, SB_VERT, dat->yScroll, TRUE);
			UpdateWindow(hwnd);
		}
	}
	dat->yScroll = desty;
	if (dat->backgroundBmpUse & CLBF_SCROLL || dat->hBmpBackground == NULL) {
		if ( !noSmooth)
			ScrollWindowEx(hwnd, 0, previousy - dat->yScroll, NULL, NULL, NULL, NULL, SW_INVALIDATE);
		else
			InvalidateRect(hwnd, NULL, FALSE);
	}
	else
		InvalidateRect(hwnd, NULL, FALSE);

	if (cfg::dat.bSkinnedScrollbar && !dat->bisEmbedded)
		CoolSB_SetScrollPos(hwnd, SB_VERT, dat->yScroll, TRUE);
	else
		SetScrollPos(hwnd, SB_VERT, dat->yScroll, TRUE);
	dat->forceScroll = 0;
}
void ExecutionLogWindow::ScrollTo(HWND hwnd, int pos)
{
    /*
    *  Keep the value in the range 0 .. (g_cItems - g_cLinesPerPage).
    */
    pos = max(pos, 0);
    pos = min(pos, (int)m_lines.size() - m_cLinesPerPage);

    /*
    *  Scroll the window contents accordingly.
    */
    ScrollWindowEx(hwnd, 0, (m_yOrigin - pos) * m_cyLine,
        NULL, NULL, NULL, NULL,
        SW_ERASE | SW_INVALIDATE);

    /*
    *  Now that the window has scrolled, a new item is at the top.
    */
    m_yOrigin = pos;

    /*
    *  And make the scrollbar look like what we think it is.
    */
    SCROLLINFO si;
    si.cbSize = sizeof(si);
    si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
    si.nPage = m_cLinesPerPage;
    si.nMin = 0;
    si.nMax = (int)m_lines.size() - 1;     /* endpoint is inclusive */
    si.nPos = m_yOrigin;
    SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
}
Beispiel #3
0
Datei: main.c Projekt: yhcflyy/ui
static void hscrollto(struct table *t, intptr_t newpos)
{
	SCROLLINFO si;
	RECT scrollArea;

	if (newpos < 0)
		newpos = 0;
	if (newpos > (t->width - t->hpagesize))
		newpos = (t->width - t->hpagesize);

	scrollArea = realClientRect(t);

	// negative because ScrollWindowEx() is "backwards"
	if (ScrollWindowEx(t->hwnd, -(newpos - t->hpos), 0,
		&scrollArea, &scrollArea, NULL, NULL,
		SW_ERASE | SW_INVALIDATE) == ERROR)
		abort();
	t->hpos = newpos;
	// TODO text in header controls doesn't redraw?

	// TODO put this in a separate function? same for vscroll?
	ZeroMemory(&si, sizeof (SCROLLINFO));
	si.cbSize = sizeof (SCROLLINFO);
	si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
	si.nPage = t->hpagesize;
	si.nMin = 0;
	si.nMax = t->width - 1;		// nMax is inclusive
	si.nPos = t->hpos;
	SetScrollInfo(t->hwnd, SB_HORZ, &si, TRUE);

	// and finally reposition the header
	repositionHeader(t);
}
Beispiel #4
0
static LRESULT
Display_OnSize(HWND hwnd)
{
	RECT rect;
	SCROLLINFO si;
	int nOldPos;

	GetClientRect(hwnd, &rect);

	/* Get the old scroll pos */
	si.cbSize = sizeof(si);
	si.fMask  = SIF_POS;
	GetScrollInfo(hwnd, SB_VERT, &si);
	nOldPos = si.nPos;

	/* Set the new page size */
	si.fMask  = SIF_PAGE;
	si.nPage  = rect.bottom;
	SetScrollInfo(hwnd, SB_VERT, &si, TRUE);

	/* Get the new scroll pos */
	si.fMask  = SIF_POS;
	GetScrollInfo(hwnd, SB_VERT, &si);

	/* If they don't match ... */
	if (nOldPos != si.nPos)
	{
		/* ... scroll the window */
		ScrollWindowEx(hwnd, 0, nOldPos - si.nPos, NULL, NULL, NULL, NULL, SW_INVALIDATE);
		UpdateWindow(hwnd);
	}

	return 0;
}
Beispiel #5
0
Datei: main.c Projekt: yhcflyy/ui
static void vscrollto(struct table *t, intptr_t newpos)
{
	SCROLLINFO si;
	RECT scrollArea;

	if (newpos < 0)
		newpos = 0;
	if (newpos > (t->count - t->pagesize))
		newpos = (t->count - t->pagesize);

	scrollArea = realClientRect(t);

	// negative because ScrollWindowEx() is "backwards"
	if (ScrollWindowEx(t->hwnd, 0, (-(newpos - t->firstVisible)) * rowHeight(t),
		&scrollArea, &scrollArea, NULL, NULL,
		SW_ERASE | SW_INVALIDATE) == ERROR)
		abort();
	t->firstVisible = newpos;

	ZeroMemory(&si, sizeof (SCROLLINFO));
	si.cbSize = sizeof (SCROLLINFO);
	si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
	si.nPage = t->pagesize;
	si.nMin = 0;
	si.nMax = t->count - 1;		// nMax is inclusive
	si.nPos = t->firstVisible;
	SetScrollInfo(t->hwnd, SB_VERT, &si, TRUE);
}
void playlist_view::move_header(bool redraw, bool update)
{

	RECT rc_playlist, rc_header;
	GetClientRect(wnd_playlist, &rc_playlist);
	GetRelativeRect(wnd_header, wnd_playlist, &rc_header);
	int header_height = calculate_header_height();

	if (rc_header.left != 0 - horizontal_offset ||
		rc_header.top != 0 ||
		rc_header.right - rc_header.left != rc_playlist.right - rc_playlist.left + horizontal_offset ||
		rc_header.bottom - rc_header.top != header_height)
	{
		SendMessage(wnd_header, WM_SETREDRAW, FALSE, 0);
		if (rc_header.bottom - rc_header.top != header_height)
		{
			RECT playlist, redraw;
			get_playlist_rect(&playlist);
			ScrollWindowEx(wnd_playlist, 0, (header_height - rc_header.bottom), &playlist, &playlist, 0, &redraw, 0);
			//			RedrawWindow(wnd_playlist,&redraw,0,RDW_INVALIDATE|RDW_UPDATENOW);
		}
		SetWindowPos(wnd_header, 0, 0 - horizontal_offset, 0, rc_playlist.right - rc_playlist.left + horizontal_offset, header_height, SWP_NOZORDER);
		if (cfg_nohscroll && update) rebuild_header(false);
		SendMessage(wnd_header, WM_SETREDRAW, TRUE, 0);
		if (redraw) RedrawWindow(wnd_header, 0, 0, RDW_UPDATENOW | RDW_INVALIDATE);
	}

}
void ScrollTo(HWND hwnd,struct ClcData *dat,int desty,int noSmooth)
{
	DWORD startTick,nowTick;
	int oldy=dat->yScroll;
	RECT clRect,rcInvalidate;
	int maxy,previousy;

	if(dat->iHotTrack!=-1 && dat->yScroll != desty) {
		InvalidateItem(hwnd,dat,dat->iHotTrack);
		dat->iHotTrack=-1;
		ReleaseCapture();
	}
	GetClientRect(hwnd,&clRect);
	rcInvalidate=clRect;
	//maxy=dat->rowHeight*GetGroupContentsCount(&dat->list,2)-clRect.bottom;
	maxy=RowHeights_GetTotalHeight(dat)-clRect.bottom;
	if(desty>maxy) desty=maxy;
	if(desty<0) desty=0;
	if(abs(desty-dat->yScroll)<4) noSmooth=1;
	if(!noSmooth && dat->exStyle&CLS_EX_NOSMOOTHSCROLLING) noSmooth=1;
	previousy=dat->yScroll;
	if(!noSmooth) {
		startTick=GetTickCount();
		for(;;) {
			nowTick=GetTickCount();
			if(nowTick>=startTick+dat->scrollTime) break;
			dat->yScroll=oldy+(desty-oldy)*(int)(nowTick-startTick)/dat->scrollTime;
			if(/*dat->backgroundBmpUse&CLBF_SCROLL || dat->hBmpBackground==NULL &&*/FALSE)
				ScrollWindowEx(hwnd,0,previousy-dat->yScroll,NULL,NULL,NULL,NULL,SW_INVALIDATE);
			else
      {
        UpdateFrameImage((WPARAM) hwnd, (LPARAM) 0); 
				//InvalidateRectZ(hwnd,NULL,FALSE);
      }
			previousy=dat->yScroll;
		  SetScrollPos(hwnd,SB_VERT,dat->yScroll,TRUE);
      UpdateFrameImage((WPARAM) hwnd, (LPARAM) 0); 
			UpdateWindow(hwnd);
		}
	}
	dat->yScroll=desty;
	if((dat->backgroundBmpUse&CLBF_SCROLL || dat->hBmpBackground==NULL) && FALSE)
		ScrollWindowEx(hwnd,0,previousy-dat->yScroll,NULL,NULL,NULL,NULL,SW_INVALIDATE);
	else
		InvalidateRectZ(hwnd,NULL,FALSE);
	SetScrollPos(hwnd,SB_VERT,dat->yScroll,TRUE);
}
Beispiel #8
0
/* on WM_HSCROLL */
void
onMSNH_HScroll(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
    PNHMapWindow data;
    SCROLLINFO si;
    int xNewPos;
    int xDelta;

    /* get window data */
    data = (PNHMapWindow) GetWindowLong(hWnd, GWL_USERDATA);

    switch (LOWORD(wParam)) {
    /* User clicked shaft left of the scroll box. */
    case SB_PAGEUP:
        xNewPos = data->xPos - data->xPageSize;
        break;

    /* User clicked shaft right of the scroll box. */
    case SB_PAGEDOWN:
        xNewPos = data->xPos + data->xPageSize;
        break;

    /* User clicked the left arrow. */
    case SB_LINEUP:
        xNewPos = data->xPos - 1;
        break;

    /* User clicked the right arrow. */
    case SB_LINEDOWN:
        xNewPos = data->xPos + 1;
        break;

    /* User dragged the scroll box. */
    case SB_THUMBTRACK:
        xNewPos = HIWORD(wParam);
        break;

    default:
        xNewPos = data->xPos;
    }

    xNewPos = max(0, min(COLNO - data->xPageSize + 1, xNewPos));
    if (xNewPos == data->xPos)
        return;

    xDelta = xNewPos - data->xPos;
    data->xPos = xNewPos;

    ScrollWindowEx(hWnd, -data->xScrTile * xDelta, 0, (CONST RECT *) NULL,
                   (CONST RECT *) NULL, (HRGN) NULL, (LPRECT) NULL,
                   SW_INVALIDATE | SW_ERASE);

    if (!GetNHApp()->bHideScrollBars) {
        si.cbSize = sizeof(si);
        si.fMask = SIF_POS;
        si.nPos = data->xPos;
        SetScrollInfo(hWnd, SB_HORZ, &si, TRUE);
    }
}
Beispiel #9
0
void Test_ScrollWindowEx()
{
	HWND hWnd;
	HRGN hrgn;
	int Result;

	/* Create a window */
	hWnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
	                    CW_USEDEFAULT, CW_USEDEFAULT, 100, 100,
	                    NULL, NULL, 0, 0);
	UpdateWindow(hWnd);

	/* Assert that no update region is there */
	hrgn = CreateRectRgn(0,0,0,0);
	Result = GetUpdateRgn(hWnd, hrgn, FALSE);
	ok(Result == NULLREGION, "Result = %d\n", Result);

	Result = ScrollWindowEx(hWnd, 20, 0, NULL, NULL, NULL, NULL, 0);
	ok(Result == SIMPLEREGION, "Result = %d\n", Result);
	Result = GetUpdateRgn(hWnd, hrgn, FALSE);
	ok(Result == NULLREGION, "Result = %d\n", Result);

	Result = ScrollWindowEx(hWnd, 20, 0, NULL, NULL, NULL, NULL, SW_INVALIDATE);
	ok(Result == SIMPLEREGION, "Result = %d\n", Result);
	Result = GetUpdateRgn(hWnd, hrgn, FALSE);
	ok(Result == SIMPLEREGION, "Result = %d\n", Result);
	UpdateWindow(hWnd);

	// test invalid update region
	DeleteObject(hrgn);
	Result = ScrollWindowEx(hWnd, 20, 0, NULL, NULL, hrgn, NULL, SW_INVALIDATE);
	ok(Result == ERROR, "Result = %d\n", Result);
	hrgn = CreateRectRgn(0,0,0,0);
	UpdateWindow(hWnd);

	// Test invalid updaterect pointer
	Result = ScrollWindowEx(hWnd, 20, 0, NULL, NULL, NULL, (LPRECT)1, SW_INVALIDATE);
	ok(Result == ERROR, "Result = %d\n", Result);
	Result = GetUpdateRgn(hWnd, hrgn, FALSE);
	ok(Result == SIMPLEREGION, "Result = %d\n", Result);

// test for alignment of rects

	DeleteObject(hrgn);
    DestroyWindow(hWnd);
}
Beispiel #10
0
DECLSPEC_HIDDEN void WINAPI ITextHostImpl_TxScrollWindowEx(ITextHost *iface, INT dx, INT dy, LPCRECT lprcScroll,
                                           LPCRECT lprcClip, HRGN hRgnUpdate, LPRECT lprcUpdate,
                                           UINT fuScroll)
{
    ITextHostImpl *This = impl_from_ITextHost(iface);
    ScrollWindowEx(This->hWnd, dx, dy, lprcScroll, lprcClip,
                   hRgnUpdate, lprcUpdate, fuScroll);
}
Beispiel #11
0
/*************************************************************************
 *		ScrollWindow (USER32.@)
 *
 */
BOOL WINAPI ScrollWindow( HWND hwnd, INT dx, INT dy,
                              const RECT *rect, const RECT *clipRect )
{
    return
        (ERROR != ScrollWindowEx( hwnd, dx, dy, rect, clipRect, 0, NULL,
                                    (rect ? 0 : SW_SCROLLCHILDREN) |
                                    SW_INVALIDATE ));
}
Beispiel #12
0
LRESULT CView::OnVScroll(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	UNREFERENCED_PARAMETER(uMsg);
	UNREFERENCED_PARAMETER(lParam);

	int yNewPos;

	switch (LOWORD(wParam))
	{
		case SB_PAGEUP: // User clicked the scroll bar shaft above the scroll box.
			yNewPos = m_yCurrentScroll - 50;
			break;

		case SB_PAGEDOWN: // User clicked the scroll bar shaft below the scroll box.
			yNewPos = m_yCurrentScroll + 50;
			break;

		case SB_LINEUP: // User clicked the top arrow.
			yNewPos = m_yCurrentScroll - 5;
			break;

		case SB_LINEDOWN: // User clicked the bottom arrow.
			yNewPos = m_yCurrentScroll + 5;
			break;

		case SB_THUMBPOSITION: // User dragged the scroll box.
			yNewPos = HIWORD(wParam);
			break;

		case SB_THUMBTRACK: // User dragging the scroll box.
			yNewPos = HIWORD(wParam);
			break;

		default:
			yNewPos = m_yCurrentScroll;
	}

	// Scroll the window.
	yNewPos = MAX(0, yNewPos);
	yNewPos = MIN( yNewPos, GetImageRect().Height() - GetClientRect().Height() );
	int yDelta = yNewPos - m_yCurrentScroll;
	m_yCurrentScroll = yNewPos;
	ScrollWindowEx(0, -yDelta, NULL, NULL, NULL, NULL, SW_INVALIDATE);

	// Reset the scroll bar.
	SCROLLINFO si;
	ZeroMemory(&si, sizeof(SCROLLINFO));
	si.cbSize = sizeof(si);
	si.fMask  = SIF_RANGE | SIF_PAGE | SIF_POS;
	si.cbSize = sizeof(si);
	si.fMask  = SIF_POS;
	si.nPos   = m_yCurrentScroll;
	SetScrollInfo(SB_VERT, si, TRUE);

	return 0;
}
Beispiel #13
0
/* on WM_VSCROLL */
void onMSNH_VScroll(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	PNHMapWindow data;
	SCROLLINFO si;
	int yNewPos;
	int yDelta;
 
	/* get window data */
	data = (PNHMapWindow)GetWindowLong(hWnd, GWL_USERDATA);

    switch(LOWORD (wParam)) 
    { 
        /* User clicked shaft left of the scroll box. */
        case SB_PAGEUP: 
             yNewPos = data->yPos-data->yPageSize; 
             break; 

        /* User clicked shaft right of the scroll box. */
        case SB_PAGEDOWN: 
             yNewPos = data->yPos+data->yPageSize; 
             break; 

        /* User clicked the left arrow. */
        case SB_LINEUP: 
             yNewPos = data->yPos-1; 
             break; 

        /* User clicked the right arrow. */
        case SB_LINEDOWN: 
             yNewPos = data->yPos+1; 
             break; 

        /* User dragged the scroll box. */
        case SB_THUMBTRACK: 
             yNewPos = HIWORD(wParam); 
             break; 

        default: 
             yNewPos = data->yPos; 
    } 

	yNewPos = max(0, min(ROWNO-data->yPageSize+1, yNewPos));
	if( yNewPos == data->yPos ) return;
	
	yDelta = yNewPos - data->yPos;
	data->yPos = yNewPos;

    ScrollWindowEx (hWnd, 0, -data->yScrTile * yDelta, 
            (CONST RECT *) NULL, (CONST RECT *) NULL, 
            (HRGN) NULL, (LPRECT) NULL, SW_INVALIDATE | SW_ERASE); 

    si.cbSize = sizeof(si); 
    si.fMask  = SIF_POS; 
    si.nPos   = data->yPos; 
    SetScrollInfo(hWnd, SB_VERT, &si, TRUE); 
}
Beispiel #14
0
static void
mi_scroll(int dx, int dy)
{
  HRGN rgn;

  rgn = CreateRectRgn(0, 0, 0, 0);
  ScrollWindowEx(g_Wnd, dx, dy, 0, 0, rgn, 0, SW_ERASE);
  InvalidateRgn(g_Wnd, rgn, 0);
  DeleteObject(rgn);
}
Beispiel #15
0
LRESULT CView::OnHScroll(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	UNREFERENCED_PARAMETER(uMsg);
	UNREFERENCED_PARAMETER(lParam);

	int xNewPos;

	switch (LOWORD(wParam))
	{
		case SB_PAGEUP: // User clicked the scroll bar shaft left of the scroll box.
			xNewPos = m_xCurrentScroll - 50;
			break;

		case SB_PAGEDOWN: // User clicked the scroll bar shaft right of the scroll box.
			xNewPos = m_xCurrentScroll + 50;
			break;

		case SB_LINEUP: // User clicked the left arrow.
			xNewPos = m_xCurrentScroll - 5;
			break;

		case SB_LINEDOWN: // User clicked the right arrow.
			xNewPos = m_xCurrentScroll + 5;
			break;

		case SB_THUMBPOSITION: // User dragged the scroll box.
			xNewPos = HIWORD(wParam);
			break;

		case SB_THUMBTRACK: // User dragging the scroll box.
			xNewPos = HIWORD(wParam);
			break;

		default:
			xNewPos = m_xCurrentScroll;
	}

	// Scroll the window.
	xNewPos = MAX(0, xNewPos);
	xNewPos = MIN( xNewPos, GetImageRect().Width() - GetClientRect().Width() );
	int xDelta = xNewPos - m_xCurrentScroll;
	m_xCurrentScroll = xNewPos;
	ScrollWindowEx(-xDelta, 0,  NULL, NULL, NULL, NULL, SW_INVALIDATE);

	// Reset the scroll bar.
	SCROLLINFO si;
	ZeroMemory(&si, sizeof(SCROLLINFO));
	si.cbSize = sizeof(si);
	si.fMask  = SIF_RANGE | SIF_PAGE | SIF_POS;
	si.fMask  = SIF_POS;
	si.nPos   = m_xCurrentScroll;
	SetScrollInfo(SB_HORZ, si, TRUE);

	return 0L;
}
Beispiel #16
0
void TLHScroll (TLWndData* pWD, int code, int pos, HWND hWndBar) {
	int pagesize;
	int newpos;
	int scrollamount;

	pagesize = pWD->tlInval.right - pWD->tlInval.left;
	newpos = pWD->iHorizontalPos;

	switch (code) {
	case SB_TOP :
		newpos = 0;
		break;

	case SB_BOTTOM :
		newpos = (pWD->iTotalWidth-pagesize);
		break;

	case SB_PAGELEFT :
		newpos -= pagesize;
		if (newpos < 0) newpos = 0;
		break;

	case SB_PAGERIGHT :
		newpos += pagesize;
		if (newpos > (pWD->iTotalWidth-pagesize)) 
			newpos = (pWD->iTotalWidth-pagesize);
		break;

	case SB_LINELEFT :
		newpos-=3;
		if (newpos < 0) newpos = 0;
		break;

	case SB_LINERIGHT :
		newpos+=3;
		if (newpos > (pWD->iTotalWidth-pagesize)) 
			newpos = (pWD->iTotalWidth-pagesize);
		break;

	case SB_THUMBPOSITION :
	case SB_THUMBTRACK :
		newpos = pos;
		break;

	default :
		return;
	}
	scrollamount = pWD->iHorizontalPos - newpos;
	pWD->iHorizontalPos = newpos;
	if (scrollamount) {
		ScrollWindowEx (pWD->hWnd, scrollamount, 0, NULL, &(pWD->tlRect),
						NULL, NULL, SW_INVALIDATE|SW_SCROLLCHILDREN); 
		UpdateWindow (pWD->hWnd);
	}
}
Beispiel #17
0
void cliScrollTo(HWND hwnd, ClcData *dat, int desty, int noSmooth)
{
	DWORD startTick, nowTick;
	int oldy = dat->yScroll;
	RECT clRect, rcInvalidate;
	int maxy, previousy;

	if (dat->iHotTrack != -1 && dat->yScroll != desty) {
		pcli->pfnInvalidateItem(hwnd, dat, dat->iHotTrack);
		dat->iHotTrack = -1;
		ReleaseCapture();
	}
	GetClientRect(hwnd, &clRect);
	rcInvalidate = clRect;
	//maxy = dat->rowHeight*GetGroupContentsCount(&dat->list,2)-clRect.bottom;
	maxy = cliGetRowTotalHeight(dat) - clRect.bottom;
	if (desty > maxy) desty = maxy;
	if (desty < 0) desty = 0;
	if (abs(desty - dat->yScroll) < 4) noSmooth = 1;
	if (!noSmooth && dat->exStyle&CLS_EX_NOSMOOTHSCROLLING) noSmooth = 1;
	previousy = dat->yScroll;

	BOOL keyDown = ((GetKeyState(VK_UP)
		| GetKeyState(VK_DOWN)
		| GetKeyState(VK_LEFT)
		| GetKeyState(VK_RIGHT)
		| GetKeyState(VK_PRIOR)
		| GetKeyState(VK_NEXT)
		| GetKeyState(VK_HOME)
		| GetKeyState(VK_END)) & 0x8000);

	if (!noSmooth && !keyDown)
	{
		startTick = GetTickCount();
		for (;;) {
			nowTick = GetTickCount();
			if (nowTick >= startTick + dat->scrollTime) break;
			dat->yScroll = oldy + (desty - oldy)*(int)(nowTick - startTick) / dat->scrollTime;
			if (/*dat->backgroundBmpUse&CLBF_SCROLL || dat->hBmpBackground == NULL  && */FALSE)
				ScrollWindowEx(hwnd, 0, previousy - dat->yScroll, NULL, NULL, NULL, NULL, SW_INVALIDATE);
			else
			{
				CallService(MS_SKINENG_UPTATEFRAMEIMAGE, (WPARAM)hwnd, (LPARAM)0);
				//InvalidateRectZ(hwnd,NULL,FALSE);
			}
			previousy = dat->yScroll;
			SetScrollPos(hwnd, SB_VERT, dat->yScroll, TRUE);
			CallService(MS_SKINENG_UPTATEFRAMEIMAGE, (WPARAM)hwnd, (LPARAM)0);
			UpdateWindow(hwnd);
		}
	}
	dat->yScroll = desty;
	CLUI__cliInvalidateRect(hwnd, NULL, FALSE);
	SetScrollPos(hwnd, SB_VERT, dat->yScroll, TRUE);
}
void CDisplayDlg::FullScreen()
{

    m_IsFullScreen  = true;
    MoveWindow(0,0,m_ScreenWidth,m_ScreenHeight);
    ScrollWindowEx(GetScrollPos(SB_HORZ),GetScrollPos(SB_VERT),NULL, NULL, NULL, NULL, SW_ERASE|SW_SCROLLCHILDREN);
    SetScrollPos(SB_HORZ,0);
    SetScrollPos(SB_VERT,0);
    ShowScrollBar(SB_HORZ,FALSE);
    ShowScrollBar(SB_VERT,FALSE);
}
Beispiel #19
0
static void scrollmsg(PluginInstance *This, UINT msg,int code, short int pos)
{
	int page;
	int dx, dy;     // amount of scrolling
	int x_orig, y_orig;

	if(!This->scrolling) return;
	if(!This->lpdib) return;

	x_orig=This->xscrollpos;
	y_orig=This->yscrollpos;

	if(msg==WM_HSCROLL) {
		page=This->windowwidth-15;
		if(page<SCROLLLINE) page=SCROLLLINE;

		switch(code) {
		case SB_LINELEFT: This->xscrollpos-=SCROLLLINE; break;
		case SB_LINERIGHT: This->xscrollpos+=SCROLLLINE; break;
		case SB_PAGELEFT: This->xscrollpos-=page; break;
		case SB_PAGERIGHT: This->xscrollpos+=page; break;
		case SB_LEFT: This->xscrollpos=0; break;
		case SB_RIGHT: This->xscrollpos=This->lpdibinfo->biWidth; break;
		case SB_THUMBTRACK: This->xscrollpos=pos; break;
		default: return;
		}
		set_scrollbars(This);
	}
	else if(msg==WM_VSCROLL) {
		page=This->windowheight-15;
		if(page<SCROLLLINE) page=SCROLLLINE;

		switch(code) {
		case SB_LINEUP: This->yscrollpos-=SCROLLLINE; break;
		case SB_LINEDOWN: This->yscrollpos+=SCROLLLINE; break;
		case SB_PAGEUP: This->yscrollpos-=page; break;
		case SB_PAGEDOWN: This->yscrollpos+=page; break;
		case SB_TOP: This->yscrollpos=0; break;
		case SB_BOTTOM: This->yscrollpos=This->lpdibinfo->biHeight; break;
		case SB_THUMBTRACK: This->yscrollpos=pos; break;
		default: return;
		}
		set_scrollbars(This);
	}

	dx= x_orig - This->xscrollpos;
	dy= y_orig - This->yscrollpos;

	if(dx || dy) {  // if any change
		// GetClientRect(This->fhWnd,&cliprect);
		ScrollWindowEx(This->fhWnd,dx,dy,NULL,NULL /*&cliprect*/,NULL,NULL,SW_INVALIDATE);
	}
}
Beispiel #20
0
/**
 * @param bIgnoreScrollPos - pass true to disregard any existing scrollbar styles.
 */
void CTextView::ResizeTextView(BOOL bIgnoreScrollPos)
{
	TEXTMETRIC tmetr;
	GetTextMetrics(&tmetr);
	SCROLLINFO sinfo;
	RECT rcClient;

	GetClientRect(m_hwnd, &rcClient);
	ZeroMemory(&sinfo, sizeof(sinfo));
	sinfo.cbSize = sizeof(sinfo);
	sinfo.fMask = SIF_POS | SIF_RANGE;
	GetScrollInfo(m_hwnd, SB_HORZ, &sinfo);
	int nOldHorPos = ! bIgnoreScrollPos ? sinfo.nPos : 0;

	sinfo.fMask = SIF_POS | SIF_PAGE | SIF_RANGE;
	sinfo.nMin = 0;
	if (sinfo.nMax < m_nMaxLineWidth - 1)
		sinfo.nMax = m_nMaxLineWidth - 1;
	sinfo.nPage = rcClient.right;
	ValidateScrollInfo(&sinfo);
	int nHorOffset = nOldHorPos - sinfo.nPos;
	SetScrollInfo(m_hwnd, SB_HORZ, &sinfo, TRUE);

	GetClientRect(m_hwnd, &rcClient);
	ZeroMemory(&sinfo, sizeof(sinfo));
	sinfo.cbSize = sizeof(sinfo);
	int nOldVertPos;
	if (! bIgnoreScrollPos)
	{
		sinfo.fMask = SIF_POS;
		GetScrollInfo(m_hwnd, SB_VERT, &sinfo);
		nOldVertPos = sinfo.nPos;
	}
	else
		nOldVertPos = sinfo.nPos = 0;
	int nNumLines = m_arrLines.GetCount();
	sinfo.fMask = SIF_POS | SIF_PAGE | SIF_RANGE;
	sinfo.nMin = 0;
	sinfo.nMax = nNumLines > 0 ? nNumLines - 1 : 0;
	sinfo.nPage = rcClient.bottom / tmetr.tmHeight;
	ValidateScrollInfo(&sinfo);
	int nVertOffset = (nOldVertPos - sinfo.nPos) * tmetr.tmHeight;
	SetScrollInfo(m_hwnd, SB_VERT, &sinfo, TRUE);

	GetClientRect(m_hwnd, &rcClient);
	// Explicitly clip output to override style CS_PARENTDC.
	ScrollWindowEx(m_hwnd, nHorOffset, nVertOffset, &rcClient, &rcClient, NULL, NULL, SW_INVALIDATE);
	UpdateWindow(m_hwnd);
}
Beispiel #21
0
void scrollVertical(gdioutput *gdi, int yInc, HWND hWnd) {
  SCROLLINFO si;
  si.cbSize=sizeof(si);
  si.fMask=SIF_ALL;
  GetScrollInfo(hWnd, SB_VERT, &si);
  if (si.nPage==0)
    yInc = 0;

  int yPos=gdi->GetOffsetY();
  int a=si.nMax-signed(si.nPage-1) - yPos;

  if ( (yInc = max( -yPos, min(yInc, a)))!=0 ) {
    yPos += yInc;
    RECT ScrollArea, ClipArea;
    GetClientRect(hWnd, &ScrollArea);
    ClipArea=ScrollArea;

    ScrollArea.top=-gdi->getHeight()-100;
    ScrollArea.bottom+=gdi->getHeight();
    ScrollArea.right=gdi->getWidth()-gdi->GetOffsetX()+15;
    ScrollArea.left = -2000;
    gdi->SetOffsetY(yPos);

    bool inv = true; //Inv = false works only for lists etc. where there are not controls in the scroll area.

    RECT invalidArea;
    ScrollWindowEx (hWnd, 0,  -yInc,
      &ScrollArea, &ClipArea,
      (HRGN) NULL, &invalidArea, SW_SCROLLCHILDREN | (inv ? SW_INVALIDATE : 0));

   //	gdi->UpdateObjectPositions();

    si.cbSize = sizeof(si);
    si.fMask  = SIF_POS;
    si.nPos   = yPos;

    SetScrollInfo(hWnd, SB_VERT, &si, TRUE);

    if (inv)
      UpdateWindow(hWnd);
    else {
      HDC hDC = GetDC(hWnd);
      IntersectClipRect(hDC, invalidArea.left, invalidArea.top, invalidArea.right, invalidArea.bottom);
      gdi->draw(hDC, ScrollArea, invalidArea);
      ReleaseDC(hWnd, hDC);
    }
  }
}
void FormMain_OnScroll(HWND hwnd, HWND hCtrl, UINT code, int pos)
{
  SCROLLINFO si;
  si.cbSize = sizeof(si);
  si.fMask = SIF_POS;
  int yNewPos;    // new position
  switch (code)
  {
      // User clicked the scroll bar shaft above the scroll box. 
    case SB_PAGEUP:
      yNewPos = yCurrentScroll - 50;
      break;

      // User clicked the scroll bar shaft below the scroll box. 
    case SB_PAGEDOWN:
      yNewPos = yCurrentScroll + 50;
      break;

      // User clicked the top arrow. 
    case SB_LINEUP:
      yNewPos = yCurrentScroll - 5;
      break;

      // User clicked the bottom arrow. 
    case SB_LINEDOWN:
      yNewPos = yCurrentScroll + 5;
      break;

      // User dragged the scroll box. 
    case SB_THUMBPOSITION:
      yNewPos = pos;
      break;

    default:
      yNewPos = yCurrentScroll;
  }
  
  si.nPos = yNewPos;

  ScrollWindowEx(hwnd, 0, -50,
    NULL, NULL, NULL, NULL, SW_INVALIDATE);
  UpdateWindow(hwnd);

  SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
  yCurrentScroll = yNewPos;
}
Beispiel #23
0
static LRESULT
Display_OnVScroll(HWND hwnd, WPARAM wParam)
{
	SCROLLINFO si;
	int nPos;

	si.cbSize = sizeof(si);
	si.fMask  = SIF_POS | SIF_RANGE | SIF_TRACKPOS;
	GetScrollInfo(hwnd, SB_VERT, &si);

	switch(LOWORD(wParam))
	{
		case SB_PAGEUP:
			nPos = si.nPos - 50;
			break;
		case SB_PAGEDOWN:
			nPos = si.nPos + 50;
			break;
		case SB_LINEUP:
			nPos = si.nPos - 10;
			break;
		case SB_LINEDOWN:
			nPos = si.nPos + 10;
			break;
		case SB_THUMBTRACK:
		case SB_THUMBPOSITION:
			nPos = si.nTrackPos;
			break;
		default:
			nPos = si.nPos;
	}

	nPos = max(nPos, si.nMin);
	nPos = min(nPos, si.nMax);
	if (nPos != si.nPos)
	{
		ScrollWindowEx(hwnd, 0, si.nPos - nPos, NULL, NULL, NULL, NULL, SW_INVALIDATE);
		si.cbSize = sizeof(si);
		si.nPos = nPos;
		si.fMask  = SIF_POS;
		SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
		UpdateWindow(hwnd);
	}

	return 0;
}
Beispiel #24
0
void HandleMouseScrollEvents(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LPSCROLLSTATE state)
{
    SCROLLINFO si;
    int Delta;
    int NewPos;

    si.cbSize = sizeof(si);
    si.fMask = SIF_PAGE;
    GetScrollInfo(hWnd, SB_VERT, &si);

    if (Globals.uLinesToScroll == WHEEL_PAGESCROLL)
    {
        NewPos = si.nPage;
    }
    else
    {
        NewPos = Globals.uLinesToScroll * 5;
    }

    if (GET_WHEEL_DELTA_WPARAM(wParam) > 0)
    {
        NewPos = state->CurrentY - NewPos;
    }
    else
    {
        NewPos = state->CurrentY + NewPos;
    }

    NewPos = min(state->MaxY, max(0, NewPos));

    if (NewPos == state->CurrentY)
    {
        return;
    }

    Delta = NewPos - state->CurrentY;

    state->CurrentY = NewPos;

    ScrollWindowEx(hWnd, 0, -Delta, NULL, NULL, NULL, NULL, SW_INVALIDATE);

    si.cbSize = sizeof(si);
    si.fMask = SIF_POS;
    si.nPos = state->CurrentY;
    SetScrollInfo(hWnd, SB_VERT, &si, TRUE);
}
void CDisplayDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
    int h = 10;
    SCROLLINFO si;
    si.cbSize = sizeof(SCROLLINFO);
    si.fMask = SIF_ALL;
    GetScrollInfo(SB_VERT, &si);
    int nOldPos = si.nPos;

    switch (nSBCode)
    {
    case SB_LINEDOWN:
        si.nPos = min(si.nPos + h, si.nMax);
        break;
    case SB_PAGEDOWN:
        si.nPos = min(si.nPos + h * 10, si.nMax);
        break;
    case SB_LINEUP:
        si.nPos = max(si.nPos - h, si.nMin);
        break;
    case SB_PAGEUP:
        si.nPos = max(si.nPos - h * 10, si.nMin);
        break;
    case SB_THUMBPOSITION:
    case SB_THUMBTRACK:
        si.nPos = si.nTrackPos;
        break;
    case SB_TOP:
        si.nPos = si.nMin;
        break;
    case SB_BOTTOM:
        si.nPos = si.nMax;
        break;
    }

    SetScrollInfo(SB_VERT, &si);
    GetScrollInfo(SB_VERT, &si); //重新获取新的位置


    ScrollWindowEx(0, nOldPos - si.nPos,NULL, NULL, NULL, NULL, SW_ERASE|SW_SCROLLCHILDREN);
    UpdateWindow();
    RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0);
    //m_ScreenDisplayer->ReflashDC();
    CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}
Beispiel #26
0
void ME_Scroll(ME_TextEditor *editor, int cx, int cy)
{
  SCROLLINFO si;
  HWND hWnd = editor->hWnd;

  si.cbSize = sizeof(SCROLLINFO);
  si.fMask = SIF_POS;
  GetScrollInfo(hWnd, SB_VERT, &si);
  si.nPos = editor->nScrollPosY -= cy;
  SetScrollInfo(hWnd, SB_VERT, &si, TRUE);
  if (editor->bRedraw)
  {
    if (abs(cy) > editor->sizeWindow.cy)
      InvalidateRect(editor->hWnd, NULL, TRUE);
    else
      ScrollWindowEx(hWnd, cx, cy, NULL, NULL, NULL, NULL, SW_ERASE|SW_INVALIDATE);
  }
}
void HeroChart::doScroll(int pos)
{
    SCROLLINFO si;
    memset(&si, 0, sizeof si);
    si.cbSize = sizeof si;
    si.fMask = SIF_RANGE | SIF_PAGE;
    GetScrollInfo(hWnd, SB_VERT, &si);
    if (pos < si.nMin) pos = si.nMin;
    if (pos > si.nMax - si.nPage + 1) pos = si.nMax - si.nPage + 1;
    si.fMask = SIF_POS;
    if (pos != scrollPos)
    {
        si.nPos = pos;
        SetScrollInfo(hWnd, SB_VERT, &si, TRUE);
        int delta = scrollPos - pos;
        scrollPos = pos;
        ScrollWindowEx(hWnd, 0, delta, NULL, NULL, NULL, NULL, SW_ERASE | SW_INVALIDATE);
    }
}
Beispiel #28
0
int
TkScrollWindow(
    Tk_Window tkwin,		/* The window to be scrolled. */
    GC gc,			/* GC for window to be scrolled. */
    int x, int y, int width, int height,
				/* Position rectangle to be scrolled. */
    int dx, int dy,		/* Distance rectangle should be moved. */
    TkRegion damageRgn)		/* Region to accumulate damage in. */
{
    HWND hwnd = TkWinGetHWND(Tk_WindowId(tkwin));
    RECT scrollRect;

    scrollRect.left = x;
    scrollRect.top = y;
    scrollRect.right = x + width;
    scrollRect.bottom = y + height;
    return (ScrollWindowEx(hwnd, dx, dy, &scrollRect, NULL, (HRGN) damageRgn,
	    NULL, 0) == NULLREGION) ? 0 : 1;
}
Beispiel #29
0
LRESULT CDataView::OnVScroll(int code, short pos, HWND hwndCtl)
{
	SCROLLINFO si;
	si.cbSize = sizeof(si);
	si.fMask = SIF_POS|SIF_PAGE;
	GetScrollInfo(SB_VERT, &si);
	int newPos = -1;
	switch (code) {
	case SB_LEFT:
		newPos = 0;
		break;
	case SB_RIGHT:
		newPos = si.nMax;
		break;
	case SB_LINELEFT:
		newPos = si.nPos - 1;
		break;
	case SB_LINERIGHT:
		newPos = si.nPos + 1;
		break;
	case SB_PAGELEFT:
		newPos = si.nPos - si.nPage;
		break;
	case SB_PAGERIGHT:
		newPos = si.nPos + si.nPage;
		break;
	case SB_THUMBPOSITION:
	case SB_THUMBTRACK:
		newPos = pos;
		break;
	}
	if (newPos != -1) {
		if (m_scale == 1.0) {
			ScrollWindowEx(0, si.nPos - newPos, 0, 0, 0, 0, SW_INVALIDATE);
		}else {
			Invalidate();
		}
		si.nPos = newPos;
		SetScrollInfo(SB_VERT, &si);
	}
	return 0;
}
Beispiel #30
0
static ELVBOOL gwscroll (GUIWIN *gw, int qty, ELVBOOL notlast)

{
    GUI_WINDOW      *gwp = (GUI_WINDOW *)gw;
    int             rows = gwp->numrows - gwp->currow;
    RECT            rect;

#ifdef FEATURE_IMAGE
    /* if we're using background images, then don't scroll because it would
     * shred the background image.
     */
    if ((normalimage || idleimage)
            && (!o_scrollbgimage(gwp) || gwp->currow != 0 || !notlast))
        return ElvFalse;

    /* adjust the number of scrolled pixels, for the background image */
    gwp->scrolled -= qty * gwp->ycsize;
#endif

    /* adjust number of rows */
    if (notlast)
        rows--;

    /* compute update RECT */
    rect.top = gwp->currow * gwp->ycsize;
    rect.left = 0;
    rect.bottom = rect.top + rows * gwp->ycsize;
    rect.right = gwp->xsize;

    /* hide caret */
    if (gwp->cursor_type != CURSOR_NONE && gwp->clientHWnd == GetFocus())
    {
        HideCaret (gwp->clientHWnd);
        gwp->cursor_type = CURSOR_NONE;
    }

    /* scroll window */
    ScrollWindowEx (gwp->clientHWnd, 0, qty * gwp->ycsize, &rect,
                    &rect, NULL, NULL, SW_INVALIDATE);

    return ElvTrue;
}