Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Verständnis-Frage TButtonControl (https://www.delphipraxis.net/159726-verstaendnis-frage-tbuttoncontrol.html)

PinkFloydFan 10. Apr 2011 12:47

Delphi-Version: 7

Verständnis-Frage TButtonControl
 
Mahlzeit!

Wieso meckert mein Compiler "Undefinierter Bezeichner: 'Checked'" bei der folgender Funktion...
TButtonControl hat doch die Eigenschaft "Checked"

Wo mache ich da den Denkfehler??

bei "(TheComp as TCustomEdit).Text " funktionierts ja auch...

Delphi-Quellcode:
function WriteIni(IniFile:String;Section:String;Key:String;TheComp:TComponent):Boolean;
Var FIni:TInifile;
begin
  result:=false;
  Try
    FIni := TIniFile.Create(IniFile+'.Ini');
    If TheComp is TCustomEdit then
    begin
      FIni.WriteString(Section,Key,(TheComp as TCustomEdit).Text);
      result:=True;
    end;
    If TheComp is TButtonControl then
    begin
      FIni.WriteBool(Section,Key,(TheComp as TButtonControl).Checked);   <---  Hier !!!
      result:=True;
    end;
    FIni.Free;
  except
    result:=false;
  end;
end;
bin für alle Denk-Anstösse dankbar!

Stefan

Thom 10. Apr 2011 13:06

AW: Verständnis-Frage TButtonControl
 
TButtonControl.Checked ist protected.

PinkFloydFan 10. Apr 2011 13:22

AW: Verständnis-Frage TButtonControl
 
Hallo Thom!

Aha.. :shock: Woher weist du das???

Etwa weils in der OH nen gelbes kleines Viereck hat??
Mir waren diese Symbole schon immer etwas suspekt..

Kennst du ne möglichkeit das trotzdem abzufragen??

PinkFloydFan 10. Apr 2011 13:38

AW: Verständnis-Frage TButtonControl
 
hat sich erledigt.. Danke trotzdem!!

habs so gelöst, dass ich nen neuen Typ deklariert habe:
Delphi-Quellcode:
....
type TMyButtonControl = class(TButtonControl);
...
...
...
function WriteIni(IniFile:String;Section:String;Key:String;TheComp:TComponent):Boolean;
Var FIni:TInifile;
begin
  result:=false;
  Try
    FIni := TIniFile.Create(IniFile+'.Ini');
    If TheComp is TCustomEdit then
    begin
      FIni.WriteString(Section,Key,(TheComp as TCustomEdit).Text);
      result:=True;
    end;
    If TheComp is TMyButtonControl then
    begin
      FIni.WriteBool(Section,Key,(TheComp as TMyButtonControl).Checked);
      result:=True;
    end;
    FIni.Free;
  except
    result:=false;
  end;
end;
nu funktionierts...

Thom 10. Apr 2011 13:41

AW: Verständnis-Frage TButtonControl
 
Ja, genau deshalb! :thumb:

Ok, Beispiel hat sich erledigt. Genau so geht's! :-D


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:14 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