Access violation with OnDrawCell Procedure in delphi

226 Views Asked by At

I'm quite new at programming, and I'm having trouble with an Access Violation in the DrawCell Procedure below.

I'm creating a maze and each cell in the 2D Array maze has a boolean attribute called "wall". When the program starts, all cells in the array are set to be a "Wall"

the access violation occurs at the line

if maze[ACol, ARow].Wall = true then




procedure TfrmMazeGame.StrGridMazeDrawCell(Sender: TObject; ACol, ARow: 
integer; Rect: TRect; State: TGridDrawState);
begin
    if maze[ACol, ARow].Wall = true then
    begin
        StrGridMaze.canvas.Brush.Color := clGreen
    end
    else if maze[ACol, ARow].Wall = false then
        StrGridMaze.canvas.Brush.Color := clblue;
    StrGridMaze.canvas.fillrect(Rect);
end;
0

There are 0 best solutions below