Autor Beitrag
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: So 27.03.11 18:44 
weil die Units bei den uses fehlen in dem mrOK definiert ist. Ins blaue reingeraten wohl die unit Dialogs.

lg elundril

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 27.03.11 18:44 
Ja, dann überleg einmal woran das liegen kann... da fehlt eine Unit in der uses Klausel.
chickenfigt1989 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 444
Erhaltene Danke: 2



BeitragVerfasst: So 27.03.11 18:46 
Daran kann es nicht liegen weil bei Form1 und Form5 ist die Unit Dialogs in den Uses drin.
Bei Form 5 wenn man auf Login klickt passiert das:
ausblenden Delphi-Quelltext
1:
2:
3:
if AccountSystemClient1.Login(edtUsername.Text, edtPassword.Text) then
  begin
    ModalResult := mrOK;

Und da geht auch das mrOk

lg
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 27.03.11 18:51 
Dann brauchst du ja dort nur schauen welche Unit es ist, woher die Konstante kommt...
chickenfigt1989 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 444
Erhaltene Danke: 2



BeitragVerfasst: So 27.03.11 18:53 
Habe jetzt die Gleichen Units eingebunden wie bei Form1, da wo das mrOk geht aber leider ohne Erfolg.

lg
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 27.03.11 18:57 
Dann hast du wohl die Unit Controls vergessen. Außerdem kannst du auch ID_OK aus der Unit Windows direkt nutzen.
chickenfigt1989 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 444
Erhaltene Danke: 2



BeitragVerfasst: So 27.03.11 18:58 
Wenn ich ID_OK benutze kommt
[Error] Project1.dpr(18): Undeclared identifier: 'ID_OK'
Hab folgende Units eingebunden:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, XPMan, ExtCtrls, jpeg, mmsystem, ComCtrls,
  sSkinManager, sButton, IdBaseComponent, IdComponent, IdTCPConnection,
  IdTCPClient, IdHTTP, IdAuthentication, Menus, URLMon, shellapi, JvGIF,
  JvComponentBase, JvTrayIcon, AccountSystem, Registry, sCheckBox;


,lg
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 27.03.11 19:05 
Dann poste doch einmal den gesamten Quelltext in der Datei...
chickenfigt1989 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 444
Erhaltene Danke: 2



BeitragVerfasst: So 27.03.11 19:07 
Quelltext Form5:
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:
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:
120:
121:
122:
123:
124:
125:
126:
127:
unit Unit5;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, XPMan, ExtCtrls, jpeg, mmsystem, ComCtrls,
  sSkinManager, sButton, IdBaseComponent, IdComponent, IdTCPConnection,
  IdTCPClient, IdHTTP, IdAuthentication, Menus, URLMon, shellapi, JvGIF,
  JvComponentBase, JvTrayIcon, AccountSystem, Registry, sCheckBox;

  
type
  TForm5 = class(TForm)
    AccountSystemClient1: TAccountSystemClient;
    edtUsername: TEdit;
    edtPassword: TEdit;
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Button2: TButton;
    CheckBox1: TsCheckBox;
    procedure Button1Click(Sender: TObject);
    procedure AccountSystemClient1LoggedIn(
      AUserLevel: TAccountSystemUserLevel; AExpired: Boolean);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure SaveLoginData;
    procedure LoadLoginData;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form5: TForm5;
  implementation

uses Unit1, Unit2;

{$R *.dfm}

procedure TForm5.Button1Click(Sender: TObject);
begin
if AccountSystemClient1.Login(edtUsername.Text, edtPassword.Text) then
  begin
    ModalResult := mrOK;
   close;
      end
  else
    ShowMessage('Falsche Benutzerdaten!');
end;


procedure TForm5.AccountSystemClient1LoggedIn(
  AUserLevel: TAccountSystemUserLevel; AExpired: Boolean);
begin
Form1.Caption := 'Farmerama Wecker Version 1.5 Herzlich Willkommen ' + Form5.AccountSystemClient1.UserName;
if AExpired then
  begin
    ShowMessage('Dein Benutzerkonto ist abgelaufen!');
    Application.Terminate;
  end
  else if AUserLevel = aulDisabled then
  begin
    ShowMessage('Dein Benutzerkonto wurde deaktiviert!');
    Application.Terminate;
  end;



end;

procedure TForm5.SaveLoginData;
var
  Reg: TRegistry;
begin
  Reg := TRegistry.Create;
  try
    Reg.RootKey := HKEY_CURRENT_USER;
    if Reg.OpenKey('Software\' + Application.Title + ' ' + ExtractFileName(Application.ExeName), True) then
    begin
      Reg.WriteString('UserName', edtUsername.Text);
      Reg.WriteString('Password', edtPassword.Text);
      Reg.WriteBool('AutoLogin', Checkbox1.Checked);
      Reg.CloseKey;
    end;
  finally
    Reg.Free;
  end;
  SaveLoginData;
  
    end;




procedure TForm5.LoadLoginData;
var
  Reg: TRegistry;
begin
  Reg := TRegistry.Create;
  try
    Reg.RootKey := HKEY_CURRENT_USER;
    if Reg.OpenKey('Software\' + Application.Title + ' ' + ExtractFileName(Application.ExeName), False) then
    begin
      edtUsername.Text := Reg.ReadString('UserName');
      edtPassword.Text := Reg.ReadString('Password');
      Checkbox1.Checked := Reg.ReadBool('AutoLogin');
      Reg.CloseKey;
    end;
  finally
    Reg.Free;
  end;
   end;
procedure TForm5.Button2Click(Sender: TObject);
begin
Application.terminate;
end;

procedure TForm5.FormCreate(Sender: TObject);
begin
LoadLoginData;
end;

end.


Lg
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 27.03.11 19:12 
Und was hat die Unit jetzt mit dem Projektquelltext zu tun, in dem der Fehler auftritt? :gruebel: :autsch:
chickenfigt1989 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 444
Erhaltene Danke: 2



BeitragVerfasst: So 27.03.11 19:13 
Hier tritt der Fehler auf:
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:
23:
24:
program Project1;

uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1},
  Unit2 in 'Unit2.pas' {Form2},
  Unit3 in 'Unit3.pas' {Form3},
  Unit4 in 'Unit4.pas' {Form4},
  Unit5 in 'Unit5.pas' {Form5};

{$R *.res}

begin
  Application.Initialize;
  Application.Title := 'Farmerama Wecker';
  Application.CreateForm(TForm2, Form2);
  Application.CreateForm(TForm5, Form5);
  IF Form5.Showmodal=ID_OK Then Begin
Form5.Free;
  Application.CreateForm(TForm1, Form1);
   Application.CreateForm(TForm3, Form3);
  Application.CreateForm(TForm4, Form4);
  Application.Run;
end.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 27.03.11 19:18 
Das heißt du hast dort wo die Unit gebraucht worden wäre, diese immer noch nicht in die Unit gepackt und wunderst dich dann, dass es immer noch nicht geht? Na, herzlichen Glückwunsch an dein logisches Denkvermögen... :roll:

Wie gesagt, schreib die Unit in die uses... in diesem Fall jetzt die Unit Windows...
chickenfigt1989 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 444
Erhaltene Danke: 2



BeitragVerfasst: So 27.03.11 19:20 
Oke Dankeschön hab sie eingebunden.
Das programm startet jetzt nur wenn ich mich einlogge wird immernoch das Programm beendet
lg
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 27.03.11 19:25 
Benenne halt erst einmal deine Formulare anständig, dann kann dir vielleicht auch jemand dabei helfen. :roll:
chickenfigt1989 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 444
Erhaltene Danke: 2



BeitragVerfasst: So 27.03.11 20:11 
Hab ein anders Problem.
Hab auf der Login Form einen Button wo man sich registrieren kann.
Hab in den Button geschrieben:
frmNewUser.show;
Allerdings wenn ich das anklicken will kommt immer eine Access Violation.
Delphi hinterlegt folgendes in ROt:
IF Form5.Showmodal=mrOK Then Begin
Form1.Free;

lg
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 27.03.11 20:17 
Weil das Formular da noch nicht erzeugt ist. Das ist ein Problem, weil du dich auf die automatische Erzeugung der Formulare durch Delphi verlässt anstatt das selbst zu machen.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var 
  NewUserForm: TfrmNewUser;
begin
  NewUserForm := TfrmNewUser.Create(Self);
  try
    NewUserForm.ShowModal;
  finally
    NewUserForm.Free;
  end;


Wie du im Projektquelltext leicht siehst, wird dieses Formular ja erst nach dem Quelltext erzeugt, in dem du es verwendest.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: So 27.03.11 20:20 
Ich möchte an der Stelle eine Verwarnung aussprechen:

Wenn hier nicht bald etwas mehr Eigeninitiative erkennbar wird, dann wird dieses Topic für 24h gesperrt, damit der Threadersteller etwas Zeit zum Nachdenken hat.

Bitte bei folgenden Antworten berücksichtigen. Danke.

_________________
We are, we were and will not be.
chickenfigt1989 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 444
Erhaltene Danke: 2



BeitragVerfasst: So 27.03.11 20:28 
Oke ich lass die Form jetzt selbst erstellen mit Klick auf den Button Neuer Benutzer.
Wie soll ich das dann mit den Code machen der beim Onklick ereigniss des Buttons auf der
Form NewUser ist? Kann ich den Drin lassen oder muss ich des irgendwie anders lösen?
lg
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 27.03.11 20:32 
Der gehört da nicht hin, ganz einfach. Das Formular fragt die Daten vom Benutzer ab und gibt dir zurück, ob der Benutzer Ok geklickt hat. Eben in ModalResult.

Wenn er Ok geklickt hat, nimmst du die Daten aus dem Formular und machst damit etwas. Aber nicht in dem Code im Formular, sondern dort wo du das Formular aufgerufen hast.
chickenfigt1989 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 444
Erhaltene Danke: 2



BeitragVerfasst: So 27.03.11 20:40 
Wenn ich auf den Button Neuen Benutzer klicke, wird die Form NewUser aufgerufen mit dem Code den du vorher gepostet hast. Das Formular wird aufgerufen und Funktioniert.
Allerdings wenn ich einen Neuen Benutzer anlegen will meckert der Compiler bei :
ausblenden Delphi-Quelltext
1:
data.AddFormField('email', frmNewUser.edtMail.Text);					

Und es kommt eine Access Violation
lg