Autor Beitrag
Mike19
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 256

Win XP, Vista, Win 7
Delphi 2005, Turbo Delphi
BeitragVerfasst: So 24.04.05 19:33 
Hallo,

eine Frage, wie kann ich die Eigenschaften Font und Style aus einem Fontdialog auslesen,einem Label zuweisen und anschl. in einer Ini-Datei Speichern. Welches Format bei ini.write... muss ich eingeben.


Wer kann mit da helfen.

Danke

Mike


Moderiert von user profile iconraziel: Topic aus Off Topic verschoben am So 24.04.2005 um 20:52
Tobias1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 454

Win 98, XP Prof
D3 Prof, D2005 Prof
BeitragVerfasst: So 24.04.05 19:35 
ausblenden Delphi-Quelltext
1:
Label1.font:=fontdialog1.Font;					

_________________
Auch das schlechteste Buch hat seine gute Seite: die letzte. (John Osborne)
Tobias1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 454

Win 98, XP Prof
D3 Prof, D2005 Prof
BeitragVerfasst: So 24.04.05 19:39 
Speichern musst du es glaub ich einzeln, also nicht alle Formatierungen auf einmal.
z.B.
writestring('Label','Schriftart',label1.font.name);

hier findest du was über Inifiles www.dsdt.info/tutorials/ini/?page=1.

_________________
Auch das schlechteste Buch hat seine gute Seite: die letzte. (John Osborne)
Mike19 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 256

Win XP, Vista, Win 7
Delphi 2005, Turbo Delphi
BeitragVerfasst: So 24.04.05 19:39 
Danke Tabias,

das mit der Umsetzung direkt während des Programms klappt ja noch, ich möchte diese Einstellungen in einer INI Speichern und da habe ich Proble bei ini.write... mit dem Format.

Mike
Blackheart
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

ME
D3Prof.-D6Standard
BeitragVerfasst: So 24.04.05 19:46 
Hoffe das Hilft !
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
  Ini: TIniFile;
begin
  Ini := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'Einstellung.ini');
  with Ini do
  begin
    WriteInteger('Schrift','Schriftfarbe',Memo1.Font.color);
    WriteString('Schrift','Schriftname',Memo1.font.name);
    WriteInteger('Schrift','Schriftgroesse',Memo1.Font.Size);
    WriteInteger('Schrift', 'Style', Integer(TFontStyle(Memo1.Font.Style)));
    WriteInteger('Fenster','Breite',Width);
    WriteInteger('Fenster','Hoehe',Height);
    WriteInteger( 'Fenster', 'Oben', Top);
    WriteInteger( 'Fenster', 'Links', Left);
    WriteBool( 'Fenster', 'Maximiert', WindowState = wsMaximized );
  end;
 Ini.Free;
 end;
end.
Mike19 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 256

Win XP, Vista, Win 7
Delphi 2005, Turbo Delphi
BeitragVerfasst: Mo 25.04.05 09:28 
Danke,


es hat mir schon weitergeholfen, in der INI steht jetzt bei ...Font.Style ein Integerwert, wenn ich den aber wieder auslesen und dann zurodnen will bekomme ich den Fehler inkompertible TYPEN "TFontStyles und Integer".


was mache ich falsch ?
rochus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 416

Win XP Prof, Fedora Core 4, SuSE 7.0
D7 Ent, D2005 Pers
BeitragVerfasst: Mo 25.04.05 09:43 
dann mach es zu einem ;)

Memo1.Font.Style := TFontStyles(Integerwert);


probier mal ob das klappt.


gruß
rochus
Mike19 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 256

Win XP, Vista, Win 7
Delphi 2005, Turbo Delphi
BeitragVerfasst: Mo 25.04.05 09:54 
Danke,

aber es kommt die gleiche Fehlermeldung.

Mein Fehler muss beim auslesen der INI sein, da ja beim Schreiben unter Wert Style ein Integerwert geschrieben wird.

Mike
rochus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 416

Win XP Prof, Fedora Core 4, SuSE 7.0
D7 Ent, D2005 Pers
BeitragVerfasst: Mo 25.04.05 10:25 
sorry hatte was vergessen:

memo1.Font.Style := [TFontStyle(INTEGERWERT)];

eckige klammern hin + "s" bei TFontStyle hin.
Blackheart
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

ME
D3Prof.-D6Standard
BeitragVerfasst: Mo 25.04.05 12:06 
ausblenden Delphi-Quelltext
1:
Memo1.Font.Style:= TFontStyles(TFontStyle(ReadInteger('Memo', 'Style', 0)));					
Blackheart
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

ME
D3Prof.-D6Standard
BeitragVerfasst: Mo 25.04.05 12:14 
Hier nochmal das Gegenstück komplett.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
procedure TForm1.FormCreate(Sender: TObject);
var
  Ini : TIniFile;
begin
  Ini := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'Einstellung.ini');
  with Ini do
  begin
    Memo1.Font.color := ReadInteger('Schrift','Schriftfarbe',0);
    Memo1.Font.Name:= ReadString('Schrift','Schriftname','MS SANS SERIF');
    Memo1.Font.Size := ReadInteger('Schrift','Schriftgroesse',10);
    Memo1.Font.Style:= TFontStyles(TFontStyle(ReadInteger('Schrift', 'Style', 0)));
    Width:= ReadInteger('Fenster','Breite',536);
    Height:= ReadInteger('Fenster','Hoehe',348);
    Top:= ReadInteger( 'Fenster', 'Oben', 100 );
    Left:= ReadInteger( 'Fenster', 'Links', 100 );
 if ReadBool( 'Fenster', 'Maximiert', false ) then
   WindowState := wsMaximized
  else
    WindowState := wsNormal;
   end;
 Ini.Free;
end;
Mike19 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 256

Win XP, Vista, Win 7
Delphi 2005, Turbo Delphi
BeitragVerfasst: Mo 25.04.05 12:24 
Danke,

nach einer kleinen Verbesserung (ini.ReadInteger..) klappt es.

Gemeinsames Wissen und Erfahrung lohnt eben doch.


Mike