Delphi-PRAXiS
Seite 4 von 4   « Erste     234   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Komponente - Constructor MainForm.Hide = Access Violation??? (https://www.delphipraxis.net/104403-komponente-constructor-mainform-hide-%3D-access-violation.html)

shmia 6. Dez 2007 10:01

Re: Komponente - Constructor MainForm.Hide = Access Violatio
 
Du brauchst auf TRegForm nicht mal Variablen; du kannst ein Property gleich einem Edit zuweisen:
Delphi-Quellcode:
   // ich lass den Prefix Reg mal weg, denn man weiss ja schon anhand der Klasse
    // worum es geht
    property FileName: String read GetFileName write SetFileName;
...
implementation
...
function TRegForm.GetFileName:string;
begin
  // du solltest deinen Controls wirklich lesbare Namen geben (Edit1 - Edit5 ist nicht so toll)
  Result := Edit4.Text;
end;

procedure TRegForm.SetFileName(const Value:string);
begin
  Edit4.Text := Value;
end;
Mit dieser Technik hast du die Daten sauber gekapselt, und der Code wird gut lesbar.


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:29 Uhr.
Seite 4 von 4   « Erste     234   

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