was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

88 Visitors Online


 
...eine Treeview beim Drag/Drop scrollen?
Autor: Damian Gorski
[ Tip ausdrucken ]  

Tip Bewertung (9):  
     


procedure TForm1.TreeView1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
if
(y < 15) then {On the upper edge - should scroll up }
SendMessage(TreeView1.Handle, WM_VSCROLL, SB_LINEUP, 0)
else if (TreeView1.Height - y < 15) then { On the lower edge - should scroll down }
SendMessage(TreeView1.Handle, WM_VSCROLL, SB_LINEDOWN, 0);
end;

{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
             ERWEITERUNG von / ENHANCEMENT sent by
           Stef Mientki (http://Punthoofd.flappie.nl)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}

{
Thomas Stutz wrote a code snippet, to scroll a treeview,
when dragging near top/bottom of a treeview.
But with his code, you had to keep your mouse moving.
Adding a timer, does the work for you.
}
....
  private
    
{ Private declarations }
    
scroll_down   :boolean;
....

procedure TForm_test_list.tv_filesDragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
(*******************************************************************************
Start auto scroll when draging near top or bottom
*******************************************************************************)
begin
  if 
y<15 then
  begin
    
scroll_down:=true;
    timer_autoscroll.Enabled:=true;
  end
  else
    if 
(list.Height-y)<15 then
    begin
      
scroll_down:=false;
      timer_autoscroll.Enabled:=true;
    end
    else 
timer_autoscroll.Enabled:=false;
end;

procedure TForm_test_list.Timer_autoscrollTimer(Sender: TObject);
(*******************************************************************************
Set timer to about 100 msec (disabled at initialization)
*******************************************************************************)
begin
  if 
scroll_down then
    
SendMessage(tv_files.Handle, WM_VSCROLL, SB_LINEUP, 0)
  else
    
SendMessage(tv_files.Handle, WM_VSCROLL, SB_LINEDOWN, 0);
end;


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners