Autor Beitrag
steve-allround
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59

Linux, Windows

BeitragVerfasst: Mo 10.10.05 19:31 
Hallo,

ich habe eine CheckBox und eine Datei test.txt
Kann mir jemand sage, wie der Quelltext ist, wie ein Wort oder eine Zahl z.B. 'on'
in der Datei gespeichert wird, wenn man die Checkbox aktiviert. Wenn man diese aber nun wieder deaktiviert, soll der Eintrag aus der Datei gelöscht werden.
Raffo
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 300



BeitragVerfasst: Mo 10.10.05 21:39 
Klär mich mal näher auf: Willst Du wissen wie man Programmeinstellungen speichert?
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mo 10.10.05 21:50 
Hut ab, keine schlechte Fragestellung wie Raffo schon sagt.
Aber jetzt mal zur Frage - Die Checkbox hast Du schon, die txt Datei auch wo ist jetzt dein Problem.
Ich schätze mal ItemIndex ist das was du suchst..

ausblenden Delphi-Quelltext
1:
2:
i:=CheckListBox1.ItemIndex;
if CheckListBox1.State[i] = cbchecked then {Tu Irgend etwas oder lass es...}
steve-allround Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59

Linux, Windows

BeitragVerfasst: Mo 10.10.05 22:17 
Nein, das meinte ich net...

Ich meinte, wenn ich nun die CheckBox anklicke und Sie aktiv ist (makiert) soll nun in einer Textdatei ein Wort oder Zahl ("on") geschrieben werden. Wenn ich aber nun die Checkbox wieder ausklicke (makierung weg) soll auch das Wort oder die Zahl in der Textdatei gelöscht werden.

Problem: Bei jeden Programmstart soll aber die CheckBox so makiert sein, ob nun ein Wort oder Zahl in der Datei steht oder nicht.

Also steht was = Box nicht aktiv
steht nichts drin = Box inaktiv..

Vielen Dank
Alstar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 827



BeitragVerfasst: Mo 10.10.05 22:18 
user profile iconBlackheart666 hat folgendes geschrieben:
Hut ab, keine schlechte Fragestellung wie Raffo schon sagt.
Aber jetzt mal zur Frage - Die Checkbox hast Du schon, die txt Datei auch wo ist jetzt dein Problem.
Ich schätze mal ItemIndex ist das was du suchst..

ausblenden Delphi-Quelltext
1:
2:
i:=CheckListBox1.ItemIndex;
if CheckListBox1.State[i] = cbchecked then {Tu Irgend etwas oder lass es...}

Ich glaube er meint eine ganz stinknormale Checkbox und keine Checklistbox ...

@steve-allround: Hoffe du hast schon ein wenig schimmer von Datei-Input/Output?

Alstar
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mo 10.10.05 22:28 
Sorry ... glatt verlesen aber, Ich schätze mal Du möchtest Einstellungen von deinem Programmm speichern.
So hört es sich zumindestens an, dann würd Ich Dir zur Ini raten.
Raffo
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 300



BeitragVerfasst: Mo 10.10.05 23:36 
Beispiel: (auf die TForm1 eine CheckBox setzen)

ausblenden volle Höhe 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:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    CheckBox1: TCheckBox;
    procedure CheckBox1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure SaveTemp(Sender: TObject;elementname:string;status:boolean);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
SaveTemp(sender,'checkbox1',checkbox1.checked);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
CheckBox1.checked:=true;
end;

procedure TForm1.SaveTemp(Sender: TObject;elementname:string;status:boolean);
var f:TextFile;
begin
AssignFile(f,'test.txt');
Rewrite(f);
Writeln(f,status);
CloseFile(f);
end;

end.
steve-allround Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59

Linux, Windows

BeitragVerfasst: Fr 14.10.05 13:35 
Was mach ich bei diesem Text?
Soll ich da noch was in meiner Form eintragen?

procedure TForm1.SaveTemp(Sender: TObject;elementname:string;status:boolean);
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Fr 14.10.05 14:30 
Was mach ich bei diesem Text?
Du hast doch den kompletten Code.
Was funktioniert denn nicht ? Kommt das als Fehlermeldung?
Dann hast warscheinlich Oben vergessen die Prozedur anzugeben.
steve-allround Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59

Linux, Windows

BeitragVerfasst: Fr 14.10.05 15:02 
Ja, was das Item ist.... Prozedur ist eingegeben.

Was sagt aber dieser Text aus?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.SaveTemp(Sender: TObject;elementname:string;status:boolean);  
var f:TextFile;  
begin  
  AssignFile(f,'test.txt');  
  Rewrite(f);  
  Writeln(f,status);  
  CloseFile(f);  
end;


Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt.
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Fr 14.10.05 23:31 
Die Prozedur SaveTemp erwartet 3 Parameter die übergibst Du mit Listbox1.Click.
Danach wird eine Textdatei erstellt die Deine Variable speichert.
Steht übrigens auch in der Delphi Hilfe !