Jump to content


Photo

Grid autoscroll when dragging ?


  • Please log in to reply
1 reply to this topic

#1 qi130

qi130
  • Members
  • 20 posts

Posted 03 January 2023 - 12:11 AM

Hello ! (and happy new year :) )

 

Is there a way to fire grid scrolling when mouse cursor approaches the top/bottom (depending on the mouse direction) of the grid while dragging ?

 

Thx.



#2 qi130

qi130
  • Members
  • 20 posts

Posted 04 January 2023 - 11:58 AM

Finally; I did it :)
 
1) global var to store Y initial value of mouse cursor

PrevMouseY:Integer;

2) set this var in the MouseDown event

PrevMouseY:=Y;

3) Add 2 small imbeded functions in DragOver event

function MouseMoveUP(y:Integer):Boolean;
begin
     if Y<PrevMouseY then begin
        PrevMouseY:=Y;
        Result:=True;
     end else
        Result:=False;

end;
function MouseMoveDown(Y:Integer):Boolean;
begin
     if Y>PrevMouseY then begin
        PrevMouseY:=Y;
        Result:=True;
     end else
        Result:=False;
end;

4) Add this code in DragOver event

i:=(GridRequete.Height - GridRequete.HeaderSize) div 4;
if MouseMoveUP(Y) and (Y < i) then GridRequete.VertScrollBar.Prior;
if MouseMoveDown(Y) and (Y > 3*i) then GridRequete.VertScrollBar.Next;

the and (Y condition prevent immediate scroll
 






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users