Autor Beitrag
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 28

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Do 07.10.04 12:53 
So ich bin gerade dabei den Texteditor von windows nachzuprogrammieren
und möchte ein paar extra features einbauen, nur scheitern bei mir
die standard sachen.

Ich möchte machen, dass wenn man auf X oder Neu klickt, dass dann
kommt, möchten sie die Änderungen an "" speichern ?
(mit ja/nein)

und wenn man auf speichern klickt und die datei schon existiert, soll
der savedialog nicht angezeigt werden(einfach speichern)

Und wie macht man die Filter (wenn nur Textdokument dass dann nur
die .txt dateien im dialog angezeigt werden und die dann auch als solche gespeichert werden ) ? :?


Zuletzt bearbeitet von F34r0fTh3D4rk am Do 15.03.07 16:31, insgesamt 1-mal bearbeitet
digi_c
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1905

W98, XP
D7 PE, Lazarus, WinAVR
BeitragVerfasst: Do 07.10.04 13:06 
x/NEU dann speichern:
Dazu würde mir das .OnClose Ereignis des Formulars einfallen. Da kannst du dann eine Messagebox aufrufen und ggF. Speichern. Beim Neu-Button genau dasselbe(du kannst einfach eine gemeinsame Prozedur schreiben)

Kein Speicherdialog:
Frage mit FileExists() ab ob die Datei existiert und lass ggF. den Speichern unter Dialog erscheinen.

Filter:
Benutze die Opendialog.Filter! Die konkrete Formatierungen stehen nochmal in der DelphiHilfe unter "TOpenDialog.Filter" :wink:
F34r0fTh3D4rk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 28

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Do 07.10.04 15:57 
ja aber wie sieht denn der code für die Message aus, da der Projektname
da ja auch noch irgendwie rein muss und ich habe bei filter
filtername eingestellt und bei filter dann .txt
aber das funktioniert nicht!

Das Speichern und öffnen sieht bei mir so aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TForm1.Speichern1Click(Sender: TObject);
begin
if savedialog1.execute then memo1.lines.savetofile(savedialog1.filename);
end;

procedure TForm1.ffnen1Click(Sender: TObject);
begin
if opendialog1.execute then
if fileexists(opendialog1.filename) then
memo1.lines.loadfromfile(opendialog1.filename);
end;
Maweki
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 197

Ubuntu Linux
Lazarus
BeitragVerfasst: Do 07.10.04 16:14 
wenn du das beim Schließen selber machen willst, würde ich das OnCloseQuery-Ereignis empfehlen.

Dort gibt es eine Variable, die heisst CanClose. Wenn sie false ist, wird das Programm nicht geschlossen. Also kannst du bei einem Druck auf Abbrechen die Variable false setzen. Bei den beiden anderen auf True und dann gegebenfalls speichern oder eben auch nich...
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: Do 07.10.04 16:22 
hallo F34r0fTh3D4rk!

nur gut, dass es copy & paste gibt! ;)

dieses konstrukt ist aber ein grober unfug.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.ffnen1Click(Sender: TObject); 
begin 
  if opendialog1.execute then 
    if fileexists(opendialog1.filename) then 
      memo1.lines.loadfromfile(opendialog1.filename); 
end;


wieso prüfst du ein file, das du ausgewählt hast, ob es auch existiert? :?:

wolltest du nicht vor dem sichern überprüfen, ob das file schon existiert und danach vorsichtshalber nachfragen, ob das bestehende file überschrieben werden soll?
es wäre auch ganz praktisch zu überprüfen, ob das file überhaupt verändert wurde, bevor man fragt, ob es gesichert werden soll, meinst nicht? :wink:

filter: die handhabung ist in der delphi-hilfe stichwort TOpenDialog.Filter beschrieben - dort sind sogar beispiele.

mfg, stefan
F34r0fTh3D4rk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 28

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Sa 09.10.04 13:08 
habs jetzt, der editor ist fertig !

Neue Features (bis jetzt): Texte mit Passwörtern verschlüsselt abspeichern und wieder entschlüsseln u.a.
F34r0fTh3D4rk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 28

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Sa 09.10.04 13:11 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.Speichern1Click(Sender: TObject);
begin
if fileexists(savedialog1.filename) then
memo1.lines.savetofile(savedialog1.filename) else
if savedialog1.execute then memo1.lines.savetofile(savedialog1.filename);
form1.caption:=savedialog1.filename + ' - Editor';
end;

procedure TForm1.ffnen1Click(Sender: TObject);
begin
if opendialog1.execute then
if fileexists(opendialog1.filename) then
memo1.lines.loadfromfile(opendialog1.filename);
end;

und bei speichern unter:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Speichernunter1Click(Sender: TObject);
begin
if savedialog1.execute then memo1.lines.savetofile(savedialog1.filename);
form1.caption:=savedialog1.filename + ' - Editor';
end;


Moderiert von user profile iconGausi: Code- durch Delphi-Tags ersetzt
agent_x
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 62

WIN 2000, Linux Kubuntu 6.06

BeitragVerfasst: Mo 13.08.07 06:49 
Hallo,
aber wie klappt das jetzt welche Format man haben will einstellen [also Filter].
Bei mir geht nähmlich die Hilfe bei Delphi nit.
Mfg agent_x
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mo 13.08.07 07:04 
user profile iconagent_x hat folgendes geschrieben:
Hallo,
aber wie klappt das jetzt welche Format man haben will einstellen [also Filter].
Bei mir geht nähmlich die Hilfe bei Delphi nit.
Mfg agent_x


Dann solltest Du vieleicht als erstens die Frage stellen wie Du die Hilfe in Delphi wieder in gange bringst. :wink:

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
agent_x
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 62

WIN 2000, Linux Kubuntu 6.06

BeitragVerfasst: Mo 13.08.07 07:06 
jo das auch hab schon gegoogelt aber niks gefunden
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mo 13.08.07 07:19 
Was kommt denn für eine Fehlermeldung bei Aufruf der Hilfe, vieleicht musst Du nur den Pfad anpassen. (Nix ! :wink: )

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
agent_x
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 62

WIN 2000, Linux Kubuntu 6.06

BeitragVerfasst: Mo 13.08.07 07:20 
bei mir kommt ne fehler meldung und die datei selbst ist glaub ich nit da.
aber könnte mir jeman dvielleicht mit dem filtern?
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mo 13.08.07 07:24 
Wenn Du das Problem mit der Hilfe gelöst hast, findest Du darin auch etwas über Filter.
Wie lautet denn die Fehlermeldung ?
Hast Du mal manuell nach der Hilfedatei gesucht.

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
agent_x
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 62

WIN 2000, Linux Kubuntu 6.06

BeitragVerfasst: Mo 13.08.07 07:25 
wie heßt die denn?
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mo 13.08.07 07:32 
Ich schätze mal die Fehlermeldung wird Dir ausgeben welche Datei nicht gefunden wurde.
Je nach dem welche Delphi Version Du hast, bei Mir heißt sie d7.hlp

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
agent_x
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 62

WIN 2000, Linux Kubuntu 6.06

BeitragVerfasst: Mo 13.08.07 07:35 
hallo,
also hab jetzt die hlp gefunden.Aber da steht kaumt etwas drin auser uber .NET Freamwork SDK
und noch ne frage:
ich hab jetzt txt's in ein zip dokument gepakt und will die einzelnen txt's in memo1 aus lesen wie oben bei F34r0fTh3D4rk.
geht das?
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mo 13.08.07 07:53 
ausblenden Delphi-Quelltext
1:
OpenDialog1.Filter := 'Textdateien (*.txt)|*.txt|Delphi-Dateien (*.rtf)|*.rtf';					

Den entsprechenden Filter mit ItemIndex ansprechen.
Neue Frage neuer Thread. :wink:

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
agent_x
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 62

WIN 2000, Linux Kubuntu 6.06

BeitragVerfasst: Mo 13.08.07 08:19 
also so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm3.ffnen1Click(Sender: TObject);
begin
if opendialog1.execute then
memo1.lines.loadfromfile(opendialog1.filename);
OpenDialog1.Filter := 'Textdateien (*.txt)|*.txt|Delphi-Dateien (*.rtf)|*.rtf';
end;

oder wie?
Regan
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Di 14.08.07 21:49 
user profile iconagent_x hat folgendes geschrieben:
also so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm3.ffnen1Click(Sender: TObject);
begin
if opendialog1.execute then
memo1.lines.loadfromfile(opendialog1.filename);
OpenDialog1.Filter := 'Textdateien (*.txt)|*.txt|Delphi-Dateien (*.rtf)|*.rtf';
end;

oder wie?

Nein, sondern:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm3.ffnen1Click(Sender: TObject);
begin
OpenDialog1.Filter := 'Textdateien (*.txt)|*.txt|Delphi-Dateien (*.rtf)|*.rtf';
if opendialog1.execute then
memo1.lines.loadfromfile(opendialog1.filename);
end;
agent_x
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 62

WIN 2000, Linux Kubuntu 6.06

BeitragVerfasst: Mi 15.08.07 07:27 
ja danke habs vorher schon raus bekommen
MfG agent_x