Hallo,
die Methode ScrollBy verschiebt nur den Bildausschnitt.
Es geht sicherlich eleganter,
aber damit(D3) wird der selectierte Node etwa in die Mitte gescrollt:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
| procedure SetNodeHalf(TV: TTreeView); var aRect : TRect; Itemh, halfH, z : Integer; begin with TV do begin Items.BeginUpdate; aRect := Selected.DisplayRect(True); Itemh := aRect.Bottom-aRect.Top; halfH := round(Height/2); if aRect.Top > halfH then begin for z := 0 to round((aRect.Top-halfH)/Itemh) do Perform(WM_VSCROLL,SB_LINEDOWN,0); end else for z := 0 to round((halfH-aRect.Top-Itemh)/Itemh) do Perform(WM_VSCROLL,SB_LINEUP,0); Items.EndUpdate; end; end; |