Autor Beitrag
SubWorx
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Mo 12.12.05 12:12 
Hi,

ich teste gerade Delphi 2005 Architect auf Windows XP SP2

Seit heute (hab übers Wochenende nichts verändert) spinnt die Interaktion mit Komponenten.

Sobald ich auch nur ein Label ändern will, bekomme ich eine EAccessViolation Exception von Delphi und von der Anwendung dann den Runtime Error 216.
Dabei sieht mein Code so aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type
  TForm1 = class(TForm)
    Label1: TLabel;
  private
  public
  end;
var
  Form1: TForm1;
implementation
{$R *.dfm}
begin
Form1.Label1.Caption := 'Text';
end.


Also eine Standard VCL Anwendung, ein Label Control und eine Zuweisung.
Kann mir jemand erklären, warum?

Hab zwar heut früh mit Pointern rumgespielt, aber das kanns ja wohl nicht sein, nach Neustart und Neuinstallation von Delphi (würg, dauert ewig)

Danke im Voraus

SubWorx


Zuletzt bearbeitet von SubWorx am Mo 12.12.05 12:32, insgesamt 1-mal bearbeitet
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Mo 12.12.05 12:30 
Hallo,
Du packst deinen Code nicht eine Procedure. Soweit ich das jetzt verstehe (ich sehs für ne VCL-Anwendung das erste mal so) liegt es daran, dass der Code vor dem erstellen von Form1 oder Label1 ausgeführt wird, denn der Runtime Error 216 steht für eine AV.

Gruß alias5000

_________________
Programmers never die, they just GOSUB without RETURN
SubWorx Threadstarter
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Mo 12.12.05 12:41 
Muuuuuuuuh ;)

Genau das war mein Problem, Danke für deine Hilfe :)

Hab die Zeile jetzt mal in FormCreate() gepackt, funktioniert ohne Probleme.


Danke nochmal und bis denne
SubWorx
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 12.12.05 12:49 
Du greifst in Zeile 16 auf eine nicht initialisierte Instanz von Form1 zu. (Der Source wird nämlich in der Form, wie er jetzt ist, bereits beim Laden des Programms ausgeführt).

Du musst einen Eventhandler (z.B. OnCreate, OnShow, o.ä.) nutzen um diese Anweisung auszuführen.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.