Thema: Delphi .ini wird nicht geladen

Einzelnen Beitrag anzeigen

tinibeenie

Registriert seit: 5. Feb 2005
Ort: Barsbüttel
34 Beiträge
 
Delphi XE6 Professional
 
#14

Re: .ini wird nicht geladen

  Alt 5. Jun 2005, 18:40
Das ist die vollständige Unit:

Delphi-Quellcode:
unit Zinsdifferenzen;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, ToolWin, ComCtrls, Buttons, Grids, IniFiles;

type
  TForm1 = class(TForm)
    Image1: TImage;
    ToolBar1: TToolBar;
    GroupBox3: TGroupBox;
    Label42: TLabel;
    Label43: TLabel;
    Label46: TLabel;
    Label47: TLabel;
    GroupBox1: TGroupBox;
    Label36: TLabel;
    Label37: TLabel;
    Label38: TLabel;
    Label39: TLabel;
    Label40: TLabel;
    Edit10: TEdit;
    Edit11: TEdit;
    Edit13: TEdit;
    Edit15: TEdit;
    Edit16: TEdit;
    Label41: TLabel;
    Label44: TLabel;
    Label45: TLabel;
    Label48: TLabel;
    Label49: TLabel;
    GroupBox2: TGroupBox;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    Button1: TButton;
    Label50: TLabel;
    Edit17: TEdit;
    Edit18: TEdit;
    Edit19: TEdit;
    GroupBox5: TGroupBox;
    Label4: TLabel;
    Label5: TLabel;
    Label51: TLabel;
    Label52: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label53: TLabel;
    Label54: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Label1: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    GroupBox4: TGroupBox;
    Edit14: TEdit;
    Edit12: TEdit;
    Label20: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Edit7: TEdit;
    Edit8: TEdit;
    Edit9: TEdit;
    Label13: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    GroupBox6: TGroupBox;
    Label16: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    Edit20: TEdit;
    Edit21: TEdit;
    Edit22: TEdit;
    Label19: TLabel;
    Label21: TLabel;
    Label22: TLabel;
    GroupBox7: TGroupBox;
    Label23: TLabel;
    Label24: TLabel;
    Label25: TLabel;
    Label26: TLabel;
    Label27: TLabel;
    Label28: TLabel;
    Edit23: TEdit;
    Edit24: TEdit;
    Edit25: TEdit;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

uses Zinsdifferenzen2, Zinsdifferenzen3;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  if (edit17.text='dd') or (edit18.text='mm') or (edit19.text='yyyy') then showmessage('Das Datum ist nicht eingetragen!')
    else
  begin
    form1.Visible:=false;
    if radiobutton1.checked then form2.visible:=true
      else form3.visible:=true;
  end;
end;

procedure TForm1.FormDestroy(Sender: TObject);
  var IniDat:TIniFile;
begin
  IniDat:=TIniFile.Create('.\Text.Ini');
  with IniDat do
  begin
    WriteString('Text', 'Edit1', Edit1.Text);
    WriteString('Text', 'Edit2', Edit2.Text);
    WriteString('Text', 'Edit3', Edit3.Text);
    WriteString('Text', 'Edit4', Edit4.Text);
    WriteString('Text', 'Edit5', Edit5.Text);
    WriteString('Text', 'Edit6', Edit6.Text);
    WriteString('Text', 'Edit7', Edit7.Text);
    WriteString('Text', 'Edit8', Edit8.Text);
    WriteString('Text', 'Edit9', Edit9.Text);
    WriteString('Text', 'Edit10', Edit10.Text);
    WriteString('Text', 'Edit11', Edit11.Text);
    WriteString('Text', 'Edit12', Edit12.Text);
    WriteString('Text', 'Edit13', Edit13.Text);
    WriteString('Text', 'Edit14', Edit14.Text);
    WriteString('Text', 'Edit15', Edit15.Text);
    WriteString('Text', 'Edit16', Edit16.Text);
    WriteString('Text', 'Edit17', Edit17.Text);
    WriteString('Text', 'Edit18', Edit18.Text);
    WriteString('Text', 'Edit19', Edit19.Text);
  end;
  IniDat.Free;
end;

procedure TForm1.FormCreate(Sender: TObject);
  var IniDat:TIniFile;
begin
  IniDat:=TIniFile.Create('.\Text.Ini');
  with IniDat do
  begin
    Edit1.Text := ReadString('Text', 'Edit1', Edit1.Text);
    Edit2.Text := ReadString('Text', 'Edit2', Edit2.Text);
    Edit3.Text := ReadString('Text', 'Edit3', Edit3.Text);
    Edit4.Text := ReadString('Text', 'Edit4', Edit4.Text);
    Edit5.Text := ReadString('Text', 'Edit5', Edit5.Text);
    Edit6.Text := ReadString('Text', 'Edit6', Edit6.Text);
    Edit7.Text := ReadString('Text', 'Edit7', Edit7.Text);
    Edit8.Text := ReadString('Text', 'Edit8', Edit8.Text);
    Edit9.Text := ReadString('Text', 'Edit9', Edit9.Text);
    Edit10.Text := ReadString('Text', 'Edit10', Edit10.Text);
    Edit11.Text := ReadString('Text', 'Edit11', Edit11.Text);
    Edit12.Text := ReadString('Text', 'Edit12', Edit12.Text);
    Edit13.Text := ReadString('Text', 'Edit13', Edit13.Text);
    Edit14.Text := ReadString('Text', 'Edit14', Edit14.Text);
    Edit15.Text := ReadString('Text', 'Edit15', Edit15.Text);
    Edit16.Text := ReadString('Text', 'Edit16', Edit16.Text);
    Edit17.Text := ReadString('Text', 'Edit17', Edit17.Text);
    Edit18.Text := ReadString('Text', 'Edit18', Edit18.Text);
    Edit19.Text := ReadString('Text', 'Edit19', Edit19.Text);
  end;
  IniDat.Free;
end;

end.
und so sieht dann die ini aus (mit irgendwelchen Werten):
Delphi-Quellcode:
[Text]
Edit1=1
Edit2=2
Edit3=3
Edit4=4
Edit5=5
Edit6=6
Edit7=7
Edit8=8
Edit9=9
Edit10=18
Edit11=19
Edit12=17
Edit13=20
Edit14=16
Edit15=21
Edit16=22
Edit17=dd
Edit18=mm
Edit19=yyyy
@Luckie: Meintest du das mit "Programmstart"?
  Mit Zitat antworten Zitat