fixed treenew using CPU time unnecessarily during drag selection

git-svn-id: svn://svn.code.sf.net/p/processhacker/code@4355 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
wj32
2011-07-25 11:04:57 +00:00
parent a6328c4bd4
commit bc48c555b3
2 changed files with 37 additions and 1 deletions
+6
View File
@@ -567,6 +567,12 @@ VOID PhTnpProcessScroll(
__in LONG DeltaX
);
BOOLEAN PhTnpCanScroll(
__in PPH_TREENEW_CONTEXT Context,
__in BOOLEAN Horizontal,
__in BOOLEAN Positive
);
// Drawing
VOID PhTnpPaint(
+31 -1
View File
@@ -4424,6 +4424,35 @@ VOID PhTnpProcessScroll(
}
}
BOOLEAN PhTnpCanScroll(
__in PPH_TREENEW_CONTEXT Context,
__in BOOLEAN Horizontal,
__in BOOLEAN Positive
)
{
SCROLLINFO scrollInfo;
scrollInfo.cbSize = sizeof(SCROLLINFO);
scrollInfo.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
if (!Horizontal)
GetScrollInfo(Context->VScrollHandle, SB_CTL, &scrollInfo);
else
GetScrollInfo(Context->HScrollHandle, SB_CTL, &scrollInfo);
if (Positive)
{
if (scrollInfo.nPage != 0)
scrollInfo.nMax -= scrollInfo.nPage - 1;
return scrollInfo.nPos < scrollInfo.nMax;
}
else
{
return scrollInfo.nPos > scrollInfo.nMin;
}
}
VOID PhTnpPaint(
__in HWND hwnd,
__in PPH_TREENEW_CONTEXT Context,
@@ -5732,7 +5761,8 @@ VOID PhTnpDragSelect(
leftOrRight = cursorPoint.x < windowRect.left || cursorPoint.x >= windowRect.right;
aboveOrBelow = cursorPoint.y < windowRect.top || cursorPoint.y >= windowRect.bottom;
if ((Context->VScrollVisible && aboveOrBelow) || (Context->HScrollVisible && leftOrRight))
if ((Context->VScrollVisible && aboveOrBelow && PhTnpCanScroll(Context, FALSE, cursorPoint.y >= windowRect.bottom)) ||
(Context->HScrollVisible && leftOrRight && PhTnpCanScroll(Context, FALSE, cursorPoint.x >= windowRect.right)))
{
SetCursorPos(cursorPoint.x, cursorPoint.y);
}