Formular öffnen funktioniert 19mal dann Fehler

Antworten
Chericks
Beiträge: 9
Registriert: Di 25. Mär 2008, 10:54

Formular öffnen funktioniert 19mal dann Fehler

Beitrag von Chericks »

Lazarus 0.9.25Beta vom 26.3.2008

Hab mal ein simples Programm für Windows CE 5.00 erstellt. Ein Formular mit einem Knopf der das Form wieder schließt (close) und einem Knopf der Form2 öffnet. Auf Form2 liegen nur ein paar Labels und ein paar buttons und edit-felder . einer von den knöpfen schließt das Fenster wieder. sonst keinerlei funktionen.
Wenn man nun das form2 immer wieder öffnet und schließt über die knöpfe erhalte ich beim 20mal oder 19mal eine Fehlermeldung "division by zero".
Was kann ich dagegen tun?

Code: Alles auswählen

unit Unit1; 
 
{$mode objfpc}{$H+}
 
interface
 
uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,unit2;
 
type
 
  { TForm1 }
 
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
  private
    { private declarations }
  public
    { public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
{ TForm1 }
 
procedure TForm1.Button1Click(Sender: TObject);
begin
  close;
end;
 
procedure TForm1.Button2Click(Sender: TObject);
begin
    label1.caption:=inttostr(strtoint(label1.caption)+1);
    form2.showmodal;
end;
 
procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
end;
 
initialization
  {$I unit1.lrs}
 
end.


Code: Alles auswählen

unit Unit2; 
 
{$mode objfpc}{$H+}
 
interface
 
uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls;
 
type
 
  { TForm2 }
 
  TForm2 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;
 
var
  Form2: TForm2;
 
implementation
 
{ TForm2 }
 
procedure TForm2.Button1Click(Sender: TObject);
begin
  close
end;
 
 
initialization
  {$I unit2.lrs}
 
end.


Code: Alles auswählen

object Form1: TForm1
  Left = 352
  Height = 122
  Top = 363
  Width = 243
  HorzScrollBar.Page = 242
  VertScrollBar.Page = 121
  Caption = 'Form1'
  ClientHeight = 122
  ClientWidth = 243
  OnClose = FormClose
  object Label1: TLabel
    Left = 16
    Height = 14
    Top = 10
    Width = 7
    Caption = '0'
    ParentColor = False
  end
  object Button1: TButton
    Left = 16
    Height = 25
    Top = 32
    Width = 75
    Caption = 'close'
    OnClick = Button1Click
    TabOrder = 0
  end
  object Button2: TButton
    Left = 112
    Height = 25
    Top = 32
    Width = 75
    Caption = 'form2'
    OnClick = Button2Click
    TabOrder = 1
  end
end


Code: Alles auswählen

object Form2: TForm2
  Left = 323
  Height = 144
  Top = 267
  Width = 293
  HorzScrollBar.Page = 292
  VertScrollBar.Page = 143
  Caption = 'Form2'
  ClientHeight = 144
  ClientWidth = 293
  object Label1: TLabel
    Left = 8
    Height = 14
    Top = 8
    Width = 32
    Caption = 'Label1'
    ParentColor = False
  end
  object Label2: TLabel
    Left = 8
    Height = 14
    Top = 24
    Width = 32
    Caption = 'Label2'
    ParentColor = False
  end
  object Label3: TLabel
    Left = 8
    Height = 14
    Top = 40
    Width = 32
    Caption = 'Label3'
    ParentColor = False
  end
  object Label4: TLabel
    Left = 51
    Height = 14
    Top = 8
    Width = 32
    Caption = 'Label4'
    ParentColor = False
  end
  object Label5: TLabel
    Left = 51
    Height = 14
    Top = 29
    Width = 32
    Caption = 'Label5'
    ParentColor = False
  end
  object Label6: TLabel
    Left = 51
    Height = 14
    Top = 47
    Width = 32
    Caption = 'Label6'
    ParentColor = False
  end
  object Button1: TButton
    Left = 101
    Height = 25
    Top = 104
    Width = 75
    Caption = 'close'
    OnClick = Button1Click
    TabOrder = 0
  end
  object Edit1: TEdit
    Left = 96
    Height = 23
    Top = 8
    Width = 80
    TabOrder = 1
    Text = 'Edit1'
  end
  object Edit2: TEdit
    Left = 96
    Height = 23
    Top = 34
    Width = 80
    TabOrder = 2
    Text = 'Edit2'
  end
  object Edit3: TEdit
    Left = 96
    Height = 23
    Top = 64
    Width = 80
    TabOrder = 3
    Text = 'Edit3'
  end
  object Button2: TButton
    Left = 184
    Height = 25
    Top = 8
    Width = 75
    Caption = 'Button2'
    TabOrder = 4
  end
  object Button3: TButton
    Left = 184
    Height = 25
    Top = 32
    Width = 75
    Caption = 'Button3'
    TabOrder = 5
  end
  object Button4: TButton
    Left = 184
    Height = 25
    Top = 62
    Width = 75
    Caption = 'Button4'
    TabOrder = 6
  end
end

Chericks
Beiträge: 9
Registriert: Di 25. Mär 2008, 10:54

Beitrag von Chericks »

Erledit, mußte die LCL für Wince und arm neu erstellen und danach funktionierte es. Vielen Dank and Christian

Antworten