Autor Beitrag
Holgerwa
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 325

WIN XP Pro, Vista Business
Delphi 7 Pro, BDS 2006 Pro
BeitragVerfasst: Mo 02.01.06 13:43 
Hallo,

ich habe einen TreeView, der mit mehr Daten gefüllt ist als dargestellt werden können, daher also eine Scrollbar hat.
Nun möchte ich feststellen, wie groß der TreeView denn sein müßte, damit die Scrollbar verschwindet.
Ist das irgendwie möglich? Es gibt ja keinen direkten Zugriff auf die Scrollbars.

Danke!
Holger
Flohzirkus94
ontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 40

Win XP Pro ; Linux 9.0

BeitragVerfasst: Mo 02.01.06 13:57 
dat kannste mit SroolBars einstellen

_________________
Ŵêŗ ħâţ ďãş Ġřąś ŵĕġğëŗâūċħţ???
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mo 02.01.06 15:31 
Hallo,

ob Scrollbars angezeigt werden kannst Du mit
TreeView1.Height-TreeView1.ClientHeight ermitteln.

Dort wird eine andere Möglichkeit dargestellt:
Scrollbar in Treeview

Diese Procedur passt die Größe eines TreeView an die vorhandenen Einträge an:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
procedure SetTV_Size(TV: TTreeView);
var aRect : TRect;
    z,max : Integer;
begin
  with TV do
    begin
    FullExpand;
    TopItem := Items[0];
    Perform(WM_HSCROLL,SB_PAGELEFT,0);
    max := 0;
    for z := 0 to Items.Count-1 do
      begin
      aRect := Items[z].DisplayRect(True);
      if aRect.Right > max then
        max := aRect.Right;
      end;//Ende for
    aRect := Items[Items.Count-1].DisplayRect(True);
    Width := max+4;            //eventuell anpassen
    Height := aRect.Bottom+4;  //        "
    ShowScrollBar(Handle, SB_VERT, FALSE);
    ShowScrollBar(Handle, SB_HORZ, FALSE);
    end;//Ende with
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  SetTV_Size(TreeView1);
end;

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Holgerwa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 325

WIN XP Pro, Vista Business
Delphi 7 Pro, BDS 2006 Pro
BeitragVerfasst: Mo 02.01.06 21:09 
Hallo,

@Flohzirkus94: Ich will ja nichts einstellen, sondern eine geeignete Größe ermitteln.

@Lannes: Perfekt, der Source-Code war war genau, was ich gesucht habe!

Vielen Dank!
Holger