Thema: Delphi Canvas.Draw klappt nicht

Einzelnen Beitrag anzeigen

Benutzerbild von implementation
implementation

Registriert seit: 5. Mai 2008
940 Beiträge
 
FreePascal / Lazarus
 
#1

Canvas.Draw klappt nicht

  Alt 1. Jan 2009, 16:08
Beim folgenden Quelltext wird immer an der Stelle
Sessions[0].Control := TControl.Create(0,0,100,100); eine Zugriffsverletzung (EAccessViolation) ausgelöst.
Woher kommt das?

Delphi-Quellcode:
interface

type TWdControl = class
  public
    Bitmap: TBitmap;
    X, Y, W, H: DWord;
    procedure Paint;dynamic;
  published
    constructor Create(X, Y, W, H: DWord);
end;

type TSession = packed record
  Control: TControl;
end;
type TSessions = packed array[0..1023] of TSession;

var Sessions: TSessions;

implementation

constructor TControl.Create(X, Y, W, H: DWord);
begin
  inherited Create;
  Self.X := X;
  Self.Y := Y;
  Self.W := W;
  Self.H := H;
  Paint;
end;


procedure TControl.Paint;
begin
  Bitmap.Canvas.Pen.Color := Windesk.Colors.LightGreen;
  Bitmap.Canvas.Brush.Color := Windesk.Colors.WorkSpace;
  Bitmap.Canvas.Rectangle(0,0,W,H);
end;

procedure DrawOnForm;
begin
  Sessions[0].Control := TControl.Create(0,0,100,100);
  AScreen^.Canvas.Draw(0,0,Sessions[0].Control.Bitmap);
end;
Marvin
  Mit Zitat antworten Zitat