Autor Beitrag
deagle
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 89



BeitragVerfasst: Fr 13.09.02 11:02 
:oops: Wenn ich eine txt im MEmo laden und was rein schreibe und es mit einem Button speichern nur es geht nicht !! :cry:
ausblenden volle Höhe 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:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Menus, ComCtrls, DB, DBTables;

type
  TForm1 = class(TForm)
    OpenDialog1: TOpenDialog;
    SaveDialog1: TSaveDialog;
    Button1: TButton;
    Button2: TButton;
    MainMenu1: TMainMenu;
    Datei1: TMenuItem;
    Beenden1: TMenuItem;
    Edit1: TEdit;
    Memo1: TMemo;
    HintergrundFarbe1: TMenuItem;
    Green1: TMenuItem;
    Red1: TMenuItem;
    Blue1: TMenuItem;
    White1: TMenuItem;
    Black1: TMenuItem;
    Label1: TLabel;
    Button3: TButton;
    Table1: TTable;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Beenden1Click(Sender: TObject);
    procedure ZumProgramm1Click(Sender: TObject);
    procedure ZumProgramm2Click(Sender: TObject);
    procedure Label1Click(Sender: TObject);
    procedure Green1Click(Sender: TObject);
    procedure Red1Click(Sender: TObject);
    procedure Blue1Click(Sender: TObject);
    procedure White1Click(Sender: TObject);
    procedure Black1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

uses Unit2, Unit4, Unit5, Unit6;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute and (OpenDialog1.FileName<>'') then
  Memo1.Lines.LoadFromFile(OpenDialog1.FileName);

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
if SaveDialog1.FileName<>'' then
  Memo1.Lines.SaveToFile(SaveDialog1.FileName)
end;

procedure TForm1.Beenden1Click(Sender: TObject);
begin
close;
end;

procedure TForm1.ZumProgramm1Click(Sender: TObject);
begin
Form5.Showmodal;
end;

procedure TForm1.ZumProgramm2Click(Sender: TObject);
begin
Form4.ShowModal
end;

procedure TForm1.Label1Click(Sender: TObject);
begin
Form6.Showmodal;
end;

procedure TForm1.Green1Click(Sender: TObject);
begin
Form1.Color := clgreen
end;

procedure TForm1.Red1Click(Sender: TObject);
begin
Form1.Color := clred
end;

procedure TForm1.Blue1Click(Sender: TObject);
begin
Form1.Color := clblue
end;

procedure TForm1.White1Click(Sender: TObject);
begin
Form1.Color := clwhite
end;

procedure TForm1.Black1Click(Sender: TObject);
begin
Form1.Color := clblack
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
memo1.lines.append(edit1.text);
end;

end.
DeCodeGuru
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1333
Erhaltene Danke: 1

Arch Linux
Eclipse
BeitragVerfasst: Fr 13.09.02 11:49 
Zitat:
ausblenden Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Button2Click(Sender: TObject); 
begin 
if SaveDialog1.FileName<>'' then 
  Memo1.Lines.SaveToFile(SaveDialog1.FileName) 
end;


wie wäre es denn, wenn man den SaveDialog ausführen würde?
Zum Beispiel mit Savedialog1.Execute :wink:

Probiers einfach nochmal.

_________________
Viele Grüße
Jakob
deagle Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 89



BeitragVerfasst: Fr 13.09.02 12:39 
muss ich das verstehn ? Kannste mir einen fertigen Code geben ?
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Fr 13.09.02 12:42 
Schau dir mal den Unterschied zwischen den beiden Proceduren Button1Click und Button2Click an. Dann solltest du feststellen was in der Button2Click-Methode fehlt!

Gruß
TINO
wwerner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 185



BeitragVerfasst: Fr 13.09.02 12:48 
Noch eine kleine Bemerkung zum Programmierstil
Gib einen Elementen RICHTIGE Namen. Also nicht unit1, unit2.... Button1....
In ein paar wochen weist du nicht mehr was unit5 macht

_________________
Gruß

Wolfgang

----------
zu hause ist es doch am schönsten
deagle Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 89



BeitragVerfasst: Fr 13.09.02 13:09 
jo thx habe es gesehen !!
deagle Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 89



BeitragVerfasst: Fr 13.09.02 13:25 
jo klappt ThX!

Wie kann ich den jetzt noch mit einem Print Dialog drucken ?
wwerner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 185



BeitragVerfasst: Fr 13.09.02 13:31 

_________________
Gruß

Wolfgang

----------
zu hause ist es doch am schönsten