Beispiel #1
0
void SetupScrollbars(HWND hwnd)
{
	SCROLLINFO si;
	RECT rect;

	GetClientRect(hwnd, &rect);

	// VERT
	nVScrollPage = min(nVMaxLines + 1, (rect.bottom - rect.top) / yChar);
	nVScrollMax  = max(0, nVMaxLines);
    nVScrollPos  = min(nVScrollPos, nVScrollMax - nVScrollPage + 1);
	
	si.cbSize	= sizeof(si);
	si.fMask	= SIF_PAGE | SIF_POS | SIF_RANGE | SIF_DISABLENOSCROLL;
	si.nMin		= 0;
	si.nMax		= nVScrollMax;
	si.nPos		= nVScrollPos;
	si.nPage	= min(nVScrollPage, nVScrollMax + 1);
	
	CoolSB_SetScrollInfo (hwnd, SB_VERT, &si, TRUE);

	// HORZ
	nHScrollPage = min(nHMaxLines + 1, (rect.right - rect.left) / xChar);
	nHScrollMax  = max(0, nHMaxLines);
    nHScrollPos  = min(nHScrollPos, nHScrollMax - nHScrollPage + 1);
	
	si.cbSize	= sizeof(si);
	si.fMask	= SIF_PAGE | SIF_POS | SIF_RANGE | SIF_DISABLENOSCROLL;
	si.nMin		= 0;
	si.nMax		= nHScrollMax;
	si.nPos		= nHScrollPos;
	si.nPage	= min(nHScrollPage, nHScrollMax + 1);
	
	CoolSB_SetScrollInfo (hwnd, SB_HORZ, &si, TRUE);
}
Beispiel #2
0
void SetArrangeScroll(int offsetY, int height, VerticalZoomCenter center)
{
	HWND hwnd = GetArrangeWnd();
	SCROLLINFO si = { sizeof(SCROLLINFO), };
	si.fMask = SIF_ALL;
	CoolSB_GetScrollInfo(hwnd, SB_VERT, &si);

	int newPos = si.nPos;
	const int objUpperHalf = offsetY + (height / 4);
	const int objMid = offsetY + (height / 2);
	const int objLowerHalf = offsetY + (height / 4) * 3;
	const int objEnd = offsetY + height;
	const int pageEnd = si.nPos + (int)si.nPage + SCROLLBAR_W;

	switch (center)
	{
	case CLIP_IN_ARRANGE:
	{
		if (offsetY < si.nPos)
			newPos = offsetY;
		else if (objEnd > pageEnd)
			newPos = objEnd - (int)si.nPage - SCROLLBAR_W;
		break;
	}
	case MID_ARRANGE:
	{
		newPos = objMid - (int)(si.nPage / 2 + 0.5f) - (int)(SCROLLBAR_W / 2 + 0.5f);
		break;
	}
	case MOUSE_CURSOR:
	{
		POINT cr;
		GetCursorPos(&cr);
		ScreenToClient(hwnd, &cr);
		newPos = objMid - cr.y;
		break;
	}
	case UPPER_HALF:
	{
		newPos = objUpperHalf - (int)(si.nPage / 2 + 0.5f) - (int)(SCROLLBAR_W / 2 + 0.5f);
		break;
	}
	case LOWER_HALF:
	{
		newPos = objLowerHalf - (int)(si.nPage / 2 + 0.5f) - (int)(SCROLLBAR_W / 2 + 0.5f);
		break;
	}
	}

	if (newPos == si.nPos)
		return;
	else if (newPos < si.nMin)
		newPos = si.nMin;
	else if (newPos > si.nMax)
		newPos = si.nMax - si.nPage + 1;

	si.nPos = newPos;
	CoolSB_SetScrollInfo(hwnd, SB_VERT, &si, true);
	SendMessage(hwnd, WM_VSCROLL, si.nPos << 16 | SB_THUMBPOSITION, NULL);
}
Beispiel #3
0
void RecalcScrollBar(HWND hwnd, struct ClcData *dat)
{
	SCROLLINFO si = { 0 };
	RECT clRect;
	NMCLISTCONTROL nm;

	RowHeight::calcRowHeights(dat, hwnd);

	GetClientRect(hwnd, &clRect);
	si.cbSize = sizeof(si);
	si.fMask = SIF_ALL;
	si.nMin = 0;
	si.nMax = pcli->pfnGetRowTotalHeight(dat) - 1;
	si.nPage = clRect.bottom;
	si.nPos = dat->yScroll;

	if (GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_CONTACTLIST) {
		if (dat->noVScrollbar == 0) {
			if (cfg::dat.bSkinnedScrollbar && !dat->bisEmbedded)
				CoolSB_SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
			else
				SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
		}
	}
	else {
		if (cfg::dat.bSkinnedScrollbar && !dat->bisEmbedded)
			CoolSB_SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
		else
			SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
	}
	ScrollTo(hwnd, dat, dat->yScroll, 1);
	nm.hdr.code = CLN_LISTSIZECHANGE;
	nm.hdr.hwndFrom = hwnd;
	nm.hdr.idFrom = GetDlgCtrlID(hwnd);
	nm.pt.y = si.nMax;
	SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM)& nm);
	//saveRecalcScrollBar(hwnd, dat);
}