Einzelnen Beitrag anzeigen

EWeiss
(Gast)

n/a Beiträge
 
#15

AW: Scrollbar Design

  Alt 14. Jun 2018, 19:34
Zitat:
Mir ist's einfach zu groß.
Zitat:
Ich habe jetzt 20-30 Zeilen mit einer TScrollBar.
Mal gezählt wie viele Zeilen das sind?
Mehr war es nämlich nicht.

Delphi-Quellcode:
constructor TSubclassedList.Create(Owner: TComponent);
 begin
   inherited;

   List := TInterfaceList.Create;
 end;

destructor TSubclassedList.Destroy;
 begin
   List.Free;
   HookedScroolBar_Destroy;

   inherited;
 end;

procedure TForm1.FindSubclassed(Comp: TWinControl; Config: TStrings; L: TSubclassedList = nil);
 var
   i: Integer;

 begin
   if Config.Values['Path'] = 'then
     Config.Values['Path'] := ExtractFilePath(ParamStr(0));

  if not Assigned(L) then
     L := TSubclassedList.Create(Comp);

  for i := 0 to Comp.ControlCount - 1 do begin
     if Comp.Controls[i] is TCustomMemo then begin
       S := HookedScroolBar_Create;
       L.List.Add(S);
       // Vertikale ScrollBar Images
       if Config.Values['VTrack'] > 'then S.VTrack :=
         S.CreateImageFromFile(Config.Values['Path'] + Config.Values['VTrack']);
       if Config.Values['VBtnUp'] > 'then S.VBtnUp :=
         S.CreateImageFromFile(Config.Values['Path'] + Config.Values['VBtnUp']);
       if Config.Values['VThumb'] > 'then S.VThumb :=
         S.CreateImageFromFile(Config.Values['Path'] + Config.Values['VThumb']);
       if Config.Values['VBtnDown'] > 'then S.VBtnDown :=
         S.CreateImageFromFile(Config.Values['Path'] + Config.Values['VBtnDown']);
       // Horizontale ScrollBar Images
       if Config.Values['HTrack'] > 'then S.HTrack :=
         S.CreateImageFromFile(Config.Values['Path'] + Config.Values['HTrack']);
       if Config.Values['HBtnLeft'] > 'then S.HBtnLeft :=
         S.CreateImageFromFile(Config.Values['Path'] + Config.Values['HBtnLeft']);
       if Config.Values['HThumb'] > 'then S.HThumb :=
         S.CreateImageFromFile(Config.Values['Path'] + Config.Values['HThumb']);
       if Config.Values['HBtnRight'] > 'then S.HBtnRight :=
         S.CreateImageFromFile(Config.Values['Path'] + Config.Values['HBtnRight']);
       // Size Images
       if Config.Values['Sizer'] > 'then S.Sizer :=
         S.CreateImageFromFile(Config.Values['Path'] + Config.Values['Sizer']);
       //
       S.Connect(Handle, Memo1.Handle);
     end else if Comp.Controls[i] is TDirectoryListBox then begin
       S := HookedScroolBar_Create;
       L.List.Add(S);
       // Vertikale ScrollBar Images
       if Config.Values['VTrack'] > 'then S.VTrack :=
         S.CreateImageFromFile(Config.Values['Path'] + Config.Values['VTrack']);
       if Config.Values['VBtnUp'] > 'then S.VBtnUp :=
         S.CreateImageFromFile(Config.Values['Path'] + Config.Values['VBtnUp']);
       if Config.Values['VThumb'] > 'then S.VThumb :=
         S.CreateImageFromFile(Config.Values['Path'] + Config.Values['VThumb']);
       if Config.Values['VBtnDown'] > 'then S.VBtnDown :=
         S.CreateImageFromFile(Config.Values['Path'] + Config.Values['VBtnDown']);
       //
       S.Connect(Handle, DirectoryListBox1.Handle);
     end;
     FindSubclassed(TWinControl(Comp.Controls[i]), Config, L);
   end;
 end;

procedure TForm1.FormCreate(Sender: TObject);
 var
   Config: TStringList;
 begin
   Config := TStringList.Create;
   try
     Config.Values['Path'] := ExtractFilePath(ParamStr(0)) + 'ScrollBarSkin\';
     // Vertikale ScrollBar Images
     Config.Values['VTrack'] := 'VTrack.png';
     Config.Values['VBtnUp'] := 'VBtnUp.png';
     Config.Values['VThumb'] := 'VThumb.png';
     Config.Values['VBtnDown'] := 'VBtnDown.png';
     // Horizontale ScrollBar Images
     Config.Values['HTrack'] := 'HTrack.png';
     Config.Values['HBtnLeft'] := 'HBtnLeft.png';
     Config.Values['HThumb'] := 'HThumb.png';
     Config.Values['HBtnRight'] := 'HBtnRight.png';
     // Size Images
     Config.Values['Sizer'] := 'Sizer.png';
     //
     FindSubclassed(Self, Config);
   finally
     Config.Free;
   end;
end;
Das gesamte Projekt hat gerade mal 145 Zeilen.. inkl. class(TForm), uses und der andere Quatsch für die VCL
Aber ja doch zu groß.

Aber gut hast es ja zurecht gefummelt.

gruss

Geändert von EWeiss (14. Jun 2018 um 19:39 Uhr)
  Mit Zitat antworten Zitat