I am getting an access violation error in the line DataPtr^.PID:=ParentID; and im not sure what is happening. I was following the tutorials for setting up pointers to use in the TreeNode and TreeView.
If i remove that line and replace the AddChildObject with AddChild it works without a problem but I need the pointer for future references.
Any Suggestions?
I am using Delphi 7.
If i remove that line and replace the AddChildObject with AddChild it works without a problem but I need the pointer for future references.
Any Suggestions?
I am using Delphi 7.
Code:
type
PData = ^TNData;
TNData = Record
PID: Integer;
SID: Integer;
end;
...
procedure MakeTheTree(udfName, xName:String);
var
xCHAct: string;
CSREFTBL: TCBTable;
DataPtr: PData;
ParentID: Integer;
begin
with AttendanceOptionsFrm do
begin
SelectedNode:=AttList.Items.Add(nil, udfName);
AttList.Items.AddChild( SelectedNode, '<All '+udfName+'>');
CSREFTBL.Open;
CSREFTBL.GoTop;
IF xName='X' then
CSREFTBL.SetFilter('TBL_NAME="X"');
IF xName='Y' then
CSREFTBL.SetFilter('TBL_NAME="Y"');
IF xName='Z' then
CSREFTBL.SetFilter('TBL_NAME="Z"');
WHILE not CSREFTBL.Eof do Begin
if CSREFTBL.FieldAsString('TBL_NAME')=xName then BEGIN
xCHAct := CSREFTBL.FieldAsString('DESC');
ParentID:=CSREFTBL.FieldAsInteger('TBL_ID');
DataPtr^.PID:=ParentID;
AttList.Items.AddChildObject(SelectedNode, xCHAct, DataPtr);
END;
CSREFTBL.Skip(1);
ENd;
CSREFTBL.Close;
end;
end;