fix cursor position, patch by Paul Ishenin (issue #8181)

git-svn-id: trunk@10533 -
This commit is contained in:
micha 2007-01-29 20:57:51 +00:00
parent d85bb5745e
commit 8e29013693
3 changed files with 15 additions and 5 deletions

View File

@ -1449,7 +1449,7 @@ type
capfAllowWinControls,// include TWinControls
capfOnlyClientAreas, // use the client areas, not the whole child area
capfRecursive, // search recursively in grand childrens
capfNoScrolling // do not add the scroll offset to Pos
capfHasScrollOffset // do not add the scroll offset to Pos (already included)
);
TControlAtPosFlags = set of TControlAtPosFlag;

View File

@ -3259,6 +3259,16 @@ begin
// check if Pos in visible client area
ClientBounds:=GetClientRect;
ScrolledOffset:=GetClientScrollOffset;
if capfHasScrollOffset in Flags then
begin
{ ClientBounds do not include scrolling offset }
inc(ClientBounds.Left, ScrolledOffset.x);
inc(ClientBounds.Right, ScrolledOffset.x);
inc(ClientBounds.Top, ScrolledOffset.y);
inc(ClientBounds.Bottom, ScrolledOffset.y);
end;
if not PtInRect(ClientBounds,Pos) then begin
//debugln(['TWinControl.ControlAtPos OUT OF CLIENTBOUNDS ',DbgSName(Self),' P=',dbgs(Pos),' ClientBounds=',dbgs(ClientBounds)]);
//DumpStack;
@ -3268,8 +3278,7 @@ begin
// map Pos to logical client area
P:=Pos;
if not (capfNoScrolling in Flags) then begin
ScrolledOffset:=GetClientScrollOffset;
if not (capfHasScrollOffset in Flags) then begin
inc(P.X,ScrolledOffset.X);
inc(P.Y,ScrolledOffset.Y);
end;
@ -3295,7 +3304,7 @@ begin
NewPos:=Pos;
NewPos.X:=NewPos.X-NewClientOrigin.X+OldClientOrigin.X;
NewPos.Y:=NewPos.Y-NewClientOrigin.Y+OldClientOrigin.Y;
LControl:=TWinControl(Result).ControlAtPos(NewPos,Flags-[capfNoScrolling]);
LControl:=TWinControl(Result).ControlAtPos(NewPos,Flags-[capfHasScrollOffset]);
//debugln(['TWinControl.RECURSED ControlAtPos Result=',DbgSName(Result),' LControl=',DbgSName(LControl),' ',dbgs(NewPos),' AllowDisabled=',AllowDisabled,' OnlyClientAreas=',OnlyClientAreas]);
if LControl<>nil then
Result:=LControl;

View File

@ -698,7 +698,8 @@ Var
if ACursor = crDefault then
begin
// statictext controls do not get WM_SETCURSOR messages...
lControl := lWinControl.ControlAtPos(P, false, true);
lControl := lWinControl.ControlAtPos(P, [capfOnlyClientAreas,
capfAllowWinControls, capfHasScrollOffset]);
if lControl = nil then
lControl := lWinControl;
if lControl.Cursor <> crDefault then