[lazarus] bugs in empassword, OnClick and dfm2lfm-converter
Rainer Hamann
rainer at hamann-kiel.de
Mon Dec 23 14:07:19 EST 2002
> On Sun, 22 Dec 2002 20:08:10 +0100
>
> Rainer Hamann <rainer at hamann-kiel.de> wrote:
> > I downloaded lazarus last friday and found the following bugs :
> >
> > - in an editbox (TEdit) it is possible to select passwordmode by
> > empassword, but in the running application passwords are shown in plain
> > text, not in selected password-characters
>
> fixed
>
> > - placing a button on the form and doubleclicking on it creates an
> > errormessage in Forms, that SysUtils can not be found, but the
> > application is compiled without any errors with the paths given in
> > Start/Preferences? (Starten/Compileroptionen) (sorry, but I use german
> > menues)
>
> see FAQ
>
> > - using conversion from *.dfm to *.lfm within lazarus creates a
> > *.lfm-file
> >
> > which must have errors inside object properties. Compilation ends with an
> > errormessage at the bracket "(" of "LazResources.Add(".
>
> Can you send me an example .dfm file with this bug?
>
>
> Mattias
you get the two units I tried to transfer as attachment
Rainer Hamann
object Anmeldung: TAnmeldung
Left = 253
Top = -3
BorderIcons = []
BorderStyle = bsSingle
Caption = 'Anmeldung'
ClientHeight = 105
ClientWidth = 209
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -10
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
Position = poMainFormCenter
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object PPasswort: TPanel
Left = 0
Top = 0
Width = 209
Height = 105
TabOrder = 1
object LPasswort1: TLabel
Left = 8
Top = 36
Width = 40
Height = 13
Caption = 'Passwort'
end
object LPasswort2: TLabel
Left = 8
Top = 60
Width = 70
Height = 13
Caption = 'Passwort (Wdh)'
end
object LInfo: TLabel
Left = 1
Top = 1
Width = 207
Height = 26
Align = alTop
AutoSize = False
Caption =
'Geben Sie das gew'#252'nschte Passwort mit mindestens 6 Zeichen zweim' +
'al ein!'
Font.Charset = DEFAULT_CHARSET
Font.Color = clRed
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
WordWrap = True
end
object BFertig: TButton
Left = 0
Top = 80
Width = 209
Height = 25
Caption = 'Passwort '#252'bernehmen'
TabOrder = 0
OnClick = BFertigClick
OnKeyDown = BFertigKeyDown
end
object EPasswort1: TEdit
Left = 96
Top = 32
Width = 105
Height = 21
MaxLength = 20
PasswordChar = '*'
TabOrder = 1
OnKeyDown = EPasswort1KeyDown
end
object EPasswort2: TEdit
Left = 96
Top = 56
Width = 105
Height = 21
MaxLength = 20
PasswordChar = '*'
TabOrder = 2
OnKeyDown = EPasswort2KeyDown
end
end
object PAnmeldung: TPanel
Left = 0
Top = 0
Width = 209
Height = 105
TabOrder = 0
object LPasswort: TLabel
Left = 8
Top = 27
Width = 40
Height = 13
Caption = 'Passwort'
end
object LUser: TLabel
Left = 8
Top = 3
Width = 69
Height = 13
Caption = 'Benutzername'
end
object BAnmelden: TButton
Left = 104
Top = 48
Width = 105
Height = 55
Caption = 'Anmelden'
TabOrder = 2
OnClick = BAnmeldenClick
OnKeyDown = BAnmeldenKeyDown
end
object EPasswort: TEdit
Left = 104
Top = 24
Width = 105
Height = 21
PasswordChar = '*'
TabOrder = 1
Text = 'gast'
OnKeyDown = EPasswortKeyDown
end
object EUser: TEdit
Left = 104
Top = 0
Width = 105
Height = 21
TabOrder = 0
Text = 'gast'
OnKeyDown = EUserKeyDown
end
object BEnde: TButton
Left = 0
Top = 76
Width = 105
Height = 27
Caption = 'Programm beenden'
TabOrder = 3
OnClick = BEndeClick
end
object BKonfiguration: TButton
Left = 0
Top = 49
Width = 105
Height = 27
Caption = 'Konfiguration'
TabOrder = 4
OnClick = BKonfigurationClick
end
end
end
unit FAnmeldung;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TAnmeldung = class(TForm)
LPasswort: TLabel;
BAnmelden: TButton;
EPasswort: TEdit;
LUser: TLabel;
EUser: TEdit;
BEnde: TButton;
BKonfiguration: TButton;
PAnmeldung: TPanel;
PPasswort: TPanel;
BFertig: TButton;
LPasswort1: TLabel;
LPasswort2: TLabel;
EPasswort1: TEdit;
EPasswort2: TEdit;
LInfo: TLabel;
procedure BAnmeldenClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure BEndeClick(Sender: TObject);
procedure BKonfigurationClick(Sender: TObject);
procedure EUserKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure EPasswortKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure EPasswort1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure EPasswort2KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure BFertigClick(Sender: TObject);
procedure BFertigKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure BAnmeldenKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
IstMitSchreiben, OstuBeenden, ok : boolean;
MySQL_Port : integer;
User, Passwort, MySQL_Host, MySQL_Datenbank, Lehrerindex, Select : string;
function Anmelden(DoConnect : boolean; var MitSchreiben : boolean) : boolean;
function Verschluesseln(s: string) : string;
procedure ErzeugeSelect;
end;
var
Anmeldung: TAnmeldung;
implementation
uses FMySQLDB, FKonfiguration, LowLevelProcs, FKurshalbjahr;
{$R *.DFM}
function TAnmeldung.Anmelden(DoConnect : boolean; var MitSchreiben : boolean) : boolean;
begin
ok := false;
PAnmeldung.Show;
PPasswort.Hide;
MySQLDB.Disconnect;
if DoConnect then begin
MySQLDB.Connect('lehrer', 'lehrer', MySQL_Datenbank, MySQL_Host, MySQL_Port);
end;
EUser.Text := '';
EPasswort.Text := '';
Lehrerindex := '';
OstuBeenden := false;
ShowModal;
MitSchreiben := IstMitSchreiben;
Anmelden := ok;
end;
function TAnmeldung.Verschluesseln(s: string) : string;
var
n, c: integer;
begin
for n := 1 to Length(s) do begin
c := ord(s[n]);
s[n]:= chr(255-c-(n mod 10));
end;
Verschluesseln := s;
end;
procedure TAnmeldung.ErzeugeSelect;
begin
if IstMitSchreiben then begin
Kurshalbjahr.Start(IstMitSchreiben);
Select := 'AND Kurse.Semester="'+Kurshalbjahr.AktuellesKurshalbjahr+'" ';
end
else begin
Select := 'AND Kurse.Lehrerindex="'+Lehrerindex+'" ';
end;
end;
procedure TAnmeldung.BAnmeldenClick(Sender: TObject);
var
Zeilenzahl, Spaltenzahl : integer;
begin
if (UpString(EUser.Text) = 'PREY') or (UpString(EUser.Text) = 'HAMANN') or (UpString(EUser.Text) = 'BENCH') then begin
IstMitSchreiben := true;
end
else begin
IstMitSchreiben := false;
end;
if MySQLDB.GetQuery('SELECT Passwort, Lehrerindex '+
'FROM Lehrer '+
'WHERE Name="'+EUser.Text+'" '+
'OR Abkuerzung="'+EUser.Text+'"', Zeilenzahl, Spaltenzahl) = 0 then begin
if Zeilenzahl > 0 then begin
MySQLDB.LiesElement(0, 0, Passwort);
MySQLDB.LiesElement(0, 1, Lehrerindex);
if Passwort = '' then begin
PPasswort.Show;
PAnmeldung.Hide;
EPasswort1.SetFocus;
exit;
end
else begin
if Passwort <> Verschluesseln(EPasswort.Text) then begin
MessageDlg('ungültiger Benutzername oder falsches Passwort!', mtError, [mbOk], 0);
exit;
end;
end;
end
else begin
MessageDlg('ungültiger Benutzername!', mtError, [mbOk], 0);
exit;
end;
end;
ErzeugeSelect;
ModalResult := mrOk;
ok := true;
end;
procedure TAnmeldung.FormCreate(Sender: TObject);
begin
IstMitSchreiben := true;
end;
procedure TAnmeldung.BEndeClick(Sender: TObject);
begin
OstuBeenden := true;
ModalResult := mrCancel;
end;
procedure TAnmeldung.BKonfigurationClick(Sender: TObject);
begin
Konfiguration.Start(false);
end;
procedure TAnmeldung.EUserKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Key = VK_RETURN then begin
EPasswort.SetFocus;
end;
end;
procedure TAnmeldung.EPasswortKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Key = VK_RETURN then begin
BAnmeldenClick(Sender);
end;
end;
procedure TAnmeldung.EPasswort1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Key = VK_RETURN then begin
EPasswort2.SetFocus;
end;
end;
procedure TAnmeldung.EPasswort2KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Key = VK_RETURN then begin
BFertig.SetFocus;
end;
end;
procedure TAnmeldung.BFertigClick(Sender: TObject);
begin
if Length(EPasswort1.Text) < 6 then begin
MessageDlg('Das Passwort muss aus mindest 6 Zeichen bestehen!', mtError, [mbOk], 0);
EPasswort1.Text := '';
EPasswort2.Text := '';
exit;
end;
if EPasswort1.Text = EPasswort2.Text then begin
if MySQLDB.SetQuery('UPDATE Lehrer '+
'SET Passwort="'+Verschluesseln(EPasswort1.Text)+'" '+
'WHERE Lehrerindex="'+Lehrerindex+'"') = 0 then begin
MessageDlg('Das Passwort wurde erfolgreich eingetragen!', mtInformation, [mbOk], 0);
EPasswort1.Text := '';
EPasswort2.Text := '';
end
else begin
MessageDlg('Das Passwort konnte nicht eingetragen werden!', mtError, [mbOk], 0);
EPasswort1.Text := '';
EPasswort2.Text := '';
exit;
end;
end
else begin
MessageDlg('Die Passwort stimmen nicht überein!', mtError, [mbOk], 0);
EPasswort1.Text := '';
EPasswort2.Text := '';
exit;
end;
ErzeugeSelect;
ModalResult := mrOk;
ok := true;
end;
procedure TAnmeldung.BFertigKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Key = VK_RETURN then begin
BFertigClick(Sender);
end;
end;
procedure TAnmeldung.BAnmeldenKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Key = VK_RETURN then begin
BAnmeldenClick(Sender);
end;
end;
end.
object Konfiguration: TKonfiguration
Left = 270
Top = 131
BorderIcons = []
BorderStyle = bsSingle
Caption = 'Konfiguration'
ClientHeight = 412
ClientWidth = 325
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
Position = poMainFormCenter
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 14
object GroupBoxKonfiguration: TGroupBox
Left = 9
Top = 9
Width = 302
Height = 164
Caption = 'Konfigurationsdaten'
TabOrder = 0
object LMySQLServer: TLabel
Left = 9
Top = 26
Width = 135
Height = 14
Caption = 'Name des MySQL-Servers :'
end
object LMySQLPort: TLabel
Left = 9
Top = 52
Width = 127
Height = 14
Caption = 'Port des MySQL-Servers :'
end
object LDatenbankname: TLabel
Left = 9
Top = 78
Width = 106
Height = 14
Caption = 'Name der Datenbank :'
end
object LBenutzername: TLabel
Left = 9
Top = 103
Width = 107
Height = 14
Caption = 'Name des Benutzers :'
end
object LBenutzerpasswort: TLabel
Left = 9
Top = 129
Width = 127
Height = 14
Caption = 'Passwort des Benutzers :'
end
object EMySQLServer: TEdit
Left = 155
Top = 22
Width = 130
Height = 22
TabOrder = 0
end
object EMySQLPort: TEdit
Left = 155
Top = 47
Width = 130
Height = 22
TabOrder = 1
Text = '3306'
end
object EDatenbankname: TEdit
Left = 155
Top = 73
Width = 130
Height = 22
TabOrder = 2
end
object EBenutzername: TEdit
Left = 155
Top = 99
Width = 130
Height = 22
Enabled = False
TabOrder = 3
end
object EBenutzerpasswort: TEdit
Left = 155
Top = 125
Width = 130
Height = 22
Enabled = False
PasswordChar = '*'
TabOrder = 4
end
end
object BAbbruch: TButton
Left = 9
Top = 379
Width = 147
Height = 27
Caption = 'Abbruch'
TabOrder = 1
OnClick = BAbbruchClick
end
object BSpeichern: TButton
Left = 164
Top = 379
Width = 147
Height = 27
Caption = 'Speichern'
TabOrder = 2
OnClick = BSpeichernClick
end
object KonfigMemo: TMemo
Left = 224
Top = 0
Width = 0
Height = 0
TabOrder = 3
Visible = False
WordWrap = False
end
object GroupBoxMenuepunkte: TGroupBox
Left = 9
Top = 241
Width = 302
Height = 131
Caption = 'Men'#252'punkte zeitweise freigeben'
TabOrder = 4
object CheckBoxEndnoteneingabe11: TCheckBox
Left = 17
Top = 26
Width = 277
Height = 18
Caption = 'Endnoteneingabe 11.Jg'
TabOrder = 0
end
object CheckBoxAbinoteneingabe: TCheckBox
Left = 17
Top = 103
Width = 277
Height = 19
Caption = 'Noteneingabe der Abiturklausuren'
TabOrder = 1
end
object CheckBoxEndnoteneingabe12: TCheckBox
Left = 17
Top = 52
Width = 277
Height = 18
Caption = 'Endnoteneingabe 12.Jg'
TabOrder = 2
end
object CheckBoxEndnoteneingabe13: TCheckBox
Left = 17
Top = 78
Width = 277
Height = 18
Caption = 'Endnoteneingabe 13.Jg'
TabOrder = 3
end
end
object GroupBoxHalbjahr: TGroupBox
Left = 9
Top = 181
Width = 302
Height = 53
Caption = 'Bearbeitungshalbjahr festlegen'
TabOrder = 5
object LHalbjahr: TLabel
Left = 9
Top = 26
Width = 91
Height = 14
Caption = 'aktiviertes Halbjahr'
end
object ComboBoxHalbjahr: TComboBox
Left = 129
Top = 22
Width = 156
Height = 22
Style = csDropDownList
ItemHeight = 14
TabOrder = 0
end
end
object CheckBoxMemo: TMemo
Left = 310
Top = 241
Width = 0
Height = 0
TabOrder = 6
Visible = False
WordWrap = False
end
end
unit FKonfiguration;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TKonfiguration = class(TForm)
GroupBoxKonfiguration: TGroupBox;
BAbbruch: TButton;
BSpeichern: TButton;
LMySQLServer: TLabel;
LMySQLPort: TLabel;
LDatenbankname: TLabel;
LBenutzername: TLabel;
LBenutzerpasswort: TLabel;
EMySQLServer: TEdit;
EMySQLPort: TEdit;
EDatenbankname: TEdit;
EBenutzername: TEdit;
EBenutzerpasswort: TEdit;
KonfigMemo: TMemo;
GroupBoxMenuepunkte: TGroupBox;
CheckBoxEndnoteneingabe11: TCheckBox;
CheckBoxAbinoteneingabe: TCheckBox;
CheckBoxEndnoteneingabe12: TCheckBox;
CheckBoxEndnoteneingabe13: TCheckBox;
GroupBoxHalbjahr: TGroupBox;
LHalbjahr: TLabel;
ComboBoxHalbjahr: TComboBox;
CheckBoxMemo: TMemo;
procedure BAbbruchClick(Sender: TObject);
procedure BSpeichernClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
IniDateiGeladen : boolean;
procedure Start(IstAdmin : boolean);
procedure IniDateiLaden;
procedure IniDateiSpeichern;
procedure GetConnectParameter(var MySQL_Host, MySQL_Datenbank, MySQL_User, MySQL_Passwort : string; var MySQL_Port : integer);
function EndnoteneingabeFreigeben(Jahrgang : string) : boolean;
end;
const
KonfigFile = 'DBKonf.ini';
var
Konfiguration: TKonfiguration;
implementation
{$R *.DFM}
uses
LowLevelProcs, FAnmeldung, FKurshalbjahr, FMySQLDB;
procedure TKonfiguration.Start(IstAdmin : boolean);
var
n : integer;
begin
GroupBoxHalbjahr.Visible := IstAdmin;
GroupBoxMenuepunkte.Visible := IstAdmin;
if not IniDateiGeladen then begin
IniDateiLaden;
end;
for n := 0 to Kurshalbjahr.ComboBoxHalbjahrname.Items.Count-1 do begin
ComboBoxHalbjahr.Items.Add(Kurshalbjahr.ComboBoxHalbjahrname.Items[n]);
end;
ComboBoxHalbjahr.ItemIndex := Kurshalbjahr.ComboBoxHalbjahrname.ItemIndex;
ShowModal;
end;
procedure TKonfiguration.BAbbruchClick(Sender: TObject);
begin
ModalResult := mrCancel;
end;
procedure TKonfiguration.BSpeichernClick(Sender: TObject);
begin
IniDateiSpeichern;
ModalResult := mrOk;
end;
procedure TKonfiguration.FormCreate(Sender: TObject);
begin
IniDateiGeladen := false;
end;
procedure TKonfiguration.IniDateiLaden;
begin
if FileExists(KonfigFile) then begin
KonfigMemo.Lines.Clear;
KonfigMemo.Lines.LoadFromFile(KonfigFile);
EMySQLServer.Text := KonfigMemo.Lines[0];
EMySQLPort.Text := KonfigMemo.Lines[1];
EDatenbankname.Text := KonfigMemo.Lines[2];
EBenutzername.Text := KonfigMemo.Lines[3];
EBenutzerpasswort.Text := KonfigMemo.Lines[4];
IniDateiGeladen := true;
end;
if FileExists('WinOstuTmp.ini') then begin
CheckBoxMemo.Lines.Clear;
CheckBoxMemo.Lines.LoadFromFile('WinOstuTmp.ini');
CheckBoxEndnoteneingabe11.Checked := CheckBoxMemo.Lines[0] = FalseTrue[1];
CheckBoxEndnoteneingabe12.Checked := CheckBoxMemo.Lines[1] = FalseTrue[1];
CheckBoxEndnoteneingabe13.Checked := CheckBoxMemo.Lines[2] = FalseTrue[1];
CheckBoxAbinoteneingabe.Checked := CheckBoxMemo.Lines[3] = FalseTrue[1];
end;
end;
procedure TKonfiguration.IniDateiSpeichern;
var
Schuljahr, Halbjahr : string;
begin
KonfigMemo.Lines.Clear;
KonfigMemo.Lines.Add(EMySQLServer.Text);
KonfigMemo.Lines.Add(EMySQLPort.Text);
KonfigMemo.Lines.Add(EDatenbankname.Text);
KonfigMemo.Lines.Add(EBenutzername.Text);
KonfigMemo.Lines.Add(EBenutzerpasswort.Text);
KonfigMemo.Lines.SaveToFile(KonfigFile);
Halbjahr := ComboBoxHalbjahr.Text;
Schuljahr := copy(Halbjahr, 1, pos(',', Halbjahr)-1);
delete(Halbjahr, 1, pos(',', Halbjahr));
while pos(' ', Halbjahr) = 1 do begin
delete(Halbjahr, 1, 1);
end;
Halbjahr := copy(Halbjahr, 1, pos('.', Halbjahr)-1);
MySQLDB.SetQuery('UPDATE MiSchulhalbjahrdaten '+
'SET Schuljahr="'+Schuljahr+'", '+
'Halbjahr="'+Halbjahr+'"');
IniDateiGeladen := true; // Editboxen sind gefüllt!
CheckBoxMemo.Lines.Clear;
CheckBoxMemo.Lines.Add(FalseTrue[ord(CheckBoxEndnoteneingabe11.Checked)]);
CheckBoxMemo.Lines.Add(FalseTrue[ord(CheckBoxEndnoteneingabe12.Checked)]);
CheckBoxMemo.Lines.Add(FalseTrue[ord(CheckBoxEndnoteneingabe13.Checked)]);
CheckBoxMemo.Lines.Add(FalseTrue[ord(CheckBoxAbinoteneingabe.Checked)]);
CheckBoxMemo.Lines.SaveToFile('WinOstuTmp.ini');
end;
procedure TKonfiguration.GetConnectParameter(var MySQL_Host, MySQL_Datenbank, MySQL_User, MySQL_Passwort : string; var MySQL_Port : integer);
begin
if not IniDateiGeladen then begin
IniDateiLaden;
end;
MySQL_Host := EMySQLServer.Text;
MySQL_Datenbank := EDatenbankname.Text;
MySQL_User := EBenutzername.Text;
MySQL_Passwort := EBenutzerpasswort.Text;
MySQL_Port := StrToInt(EMySQLPort.Text);
end;
function TKonfiguration.EndnoteneingabeFreigeben(Jahrgang : string) : boolean;
begin
if pos('11.', Jahrgang) > 0 then begin
EndnoteneingabeFreigeben := CheckBoxEndnoteneingabe11.Checked;
exit;
end;
if pos('12.', Jahrgang) > 0 then begin
EndnoteneingabeFreigeben := CheckBoxEndnoteneingabe12.Checked;
exit;
end;
if pos('13.', Jahrgang) > 0 then begin
EndnoteneingabeFreigeben := CheckBoxEndnoteneingabe13.Checked;
exit;
end;
EndnoteneingabeFreigeben := false;
end;
end.
More information about the Lazarus
mailing list