Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi VertScrollBar (https://www.delphipraxis.net/140295-vertscrollbar.html)

knochen 15. Sep 2009 15:18


VertScrollBar
 
Hallo zusammen,

wir haben in meiner Firma eine Applikation mit ca. 1500 Forms. Auf vielen dieser Formss befinden sich Scrollboxen. Bei fast allen dieser Forms und Scrollboxen haben die Eigenschaften VertScrollBar.Tracking den Wert False.
Das ist so, da dies der Defaultwert ist. Wie kann ich mit vertretbarem Aufwand erreichen, das diese Eigenschaften in allen Forms und allen Scrollboxen auf True gesetzt werden? Idelaerweise das Ganze auch noch für die Eigenschaft HorzScrollBar.Tracking?

Vererbung ist in meinem Fall keine Alternative. Geben die G-Experts da vielleicht was her? Ich habe auf jeden Fall noch nichts gefunden.

Vielen Dank im Voraus.

himitsu 15. Sep 2009 16:02

Re: VertScrollBar
 
so auf die Schnelle fällt mir nur der direkte Weg ein

dafür müssen die Forms (DFMs) aber im Textformat gespeichert sein
Delphi-Quellcode:
var SL: TStringList;
begin
  SL := TStringList.Create;

  SL.LoadFromFile('form.dfm');
  if (SL.Count > 0) and (Pos('object ', SL[0]) > 0) then begin
    SL.Text := StringReplace(SL.Text, ': TScrollBox'#13#10,
      ': TScrollBox'#13#10'HorzScrollBar.Tracking = True'#13#10
      + 'VertScrollBar.Tracking = True'#13#10, [rfReplaceAll, rfIgnoreCase]);
    SL.SaveToFile('form.dfm');
  end;

  SL.Free;
end;
und falls schon Einiges gesetzt ist, dann sollte man vorher mal prüfen, ob ".Tracking" noch nicht vorhanden ist ... könnte sein, das Delphi keine mehrfachvorkommen mag oder nur die letzen/alten Werte nimmt
Delphi-Quellcode:
var SL: TStringList;
  Th, Tv, i: Integer;
begin
  SL := TStringList.Create;

  SL.LoadFromFile('form.dfm');
  if (SL.Count > 0) and (Pos('object ', SL[0]) > 0) then begin
    Th := -1;
    Tv := -1;
    for i := SL.Count - 1 downto 0 do begin
      if Pos(' end', SL[i]) > 0 then begin
        Th := -1;
        Tv := -1;
      end;
      if Pos('HorzScrollBar.Tracking = ', SL[i]) > 0 then Th := i;
      if Pos('VertScrollBar.Tracking = ', SL[i]) > 0 then Tv := i;
      if (Pos(' object ', SL[i]) > 0) and Pos(': TScrollBox', SL[i]) > 0 then begin
        if Th >= 0 then begin
          SL[Th] := 'HorzScrollBar.Tracking = True';
          Th := -1;
        end else SL.Insert(i + 1, 'HorzScrollBar.Tracking = True');
        if Tv >= 0 then begin
          SL[Tv] := 'VertScrollBar.Tracking = True';
          Tv := -1;
        end else SL.Insert(i + 1, 'VertScrollBar.Tracking = True');
      end;
    end;
    SL.SaveToFile('form.dfm');
  end;

  SL.Free;
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:02 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz