Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Form Creation and dynamic arrays.

PerranPerran Member Posts: 241
I'm working on a program to analyze a very specialized kind of file that is generated by laboratory equipment [flow cytometer.] For every file opened, I want to have an unlimited number of forms created that will hold graphics displays of the data. I'm using a dynamic array of records to hold the graphics displays and some associated data. So I have a record declaration like:
[code]
TlmHistogramData = RECORD
HistogramNumAxes : INTEGER;
ShowAllPoints : BOOLEAN;
Par1, Par2, Par3 : INTEGER;
Resolution : INTEGER;
ItsForm : TlmHistogramFrm; //This form is defined
END;
[/code]
I have declared a dynamic array of the above records. I have a procedure to add the above record to the array and its form to the list. This code works to make ONE form, but no more.
[code]
procedure TlmDataModule.AddHistogram(HistoDetails : TlmHistogramData);
begin
INC(NumHistograms);
SetLength(HistoGramList,NumHistograms);
HistoGramList[NumHistograms]:=HistoDetails;
HistoGramList[NumHistograms].ItsForm:=TlmHistogramFrm.Create(self);
WITH HistoGramList[NumHistograms].ItsForm DO
BEGIN
XAxis:=HistoDetails.Par1;
YAxis:=HistoDetails.Par2;
Show;
END;
end;
[/code]
Anybody got any ideas? This is Kylix, but Delphi code should work. I'm getting an AV fault on the second call to the form's create method.
Thanks in advance....Perran

Comments

  • zibadianzibadian Member Posts: 6,349
    : I'm working on a program to analyze a very specialized kind of file that is generated by laboratory equipment [flow cytometer.] For every file opened, I want to have an unlimited number of forms created that will hold graphics displays of the data. I'm using a dynamic array of records to hold the graphics displays and some associated data. So I have a record declaration like:
    : [code]
    : TlmHistogramData = RECORD
    : HistogramNumAxes : INTEGER;
    : ShowAllPoints : BOOLEAN;
    : Par1, Par2, Par3 : INTEGER;
    : Resolution : INTEGER;
    : ItsForm : TlmHistogramFrm; //This form is defined
    : END;
    : [/code]
    : I have declared a dynamic array of the above records. I have a procedure to add the above record to the array and its form to the list. This code works to make ONE form, but no more.
    : [code]
    : procedure TlmDataModule.AddHistogram(HistoDetails : TlmHistogramData);
    : begin
    : INC(NumHistograms);
    : SetLength(HistoGramList,NumHistograms);
    : HistoGramList[NumHistograms]:=HistoDetails;
    : HistoGramList[NumHistograms].ItsForm:=TlmHistogramFrm.Create(self);
    : WITH HistoGramList[NumHistograms].ItsForm DO
    : BEGIN
    : XAxis:=HistoDetails.Par1;
    : YAxis:=HistoDetails.Par2;
    : Show;
    : END;
    : end;
    : [/code]
    : Anybody got any ideas? This is Kylix, but Delphi code should work. I'm getting an AV fault on the second call to the form's create method.
    : Thanks in advance....Perran
    :
    You could try to let the forms be owned by the application and niot by the datamodule. If that doesn't work, then here's an alternative, which I successfully used during the last few years:
    Use a TTabControl with its tabs created dynamically. For this to work you need to store the histogram info in an special object, which can also be stored in the Tabs property of the control. All you need to do is to redraw the histogram each time the user selects another tab.
  • PerranPerran Member Posts: 241
    : : I'm working on a program to analyze a very specialized kind of file that is generated by laboratory equipment [flow cytometer.] For every file opened, I want to have an unlimited number of forms created that will hold graphics displays of the data. I'm using a dynamic array of records to hold the graphics displays and some associated data. So I have a record declaration like:
    : : [code]
    : : TlmHistogramData = RECORD
    : : HistogramNumAxes : INTEGER;
    : : ShowAllPoints : BOOLEAN;
    : : Par1, Par2, Par3 : INTEGER;
    : : Resolution : INTEGER;
    : : ItsForm : TlmHistogramFrm; //This form is defined
    : : END;
    : : [/code]
    : : I have declared a dynamic array of the above records. I have a procedure to add the above record to the array and its form to the list. This code works to make ONE form, but no more.
    : : [code]
    : : procedure TlmDataModule.AddHistogram(HistoDetails : TlmHistogramData);
    : : begin
    : : INC(NumHistograms);
    : : SetLength(HistoGramList,NumHistograms);
    : : HistoGramList[NumHistograms]:=HistoDetails;
    : : HistoGramList[NumHistograms].ItsForm:=TlmHistogramFrm.Create(self);
    : : WITH HistoGramList[NumHistograms].ItsForm DO
    : : BEGIN
    : : XAxis:=HistoDetails.Par1;
    : : YAxis:=HistoDetails.Par2;
    : : Show;
    : : END;
    : : end;
    : : [/code]
    : : Anybody got any ideas? This is Kylix, but Delphi code should work. I'm getting an AV fault on the second call to the form's create method.
    : : Thanks in advance....Perran
    : :
    : You could try to let the forms be owned by the application and niot by the datamodule. If that doesn't work, then here's an alternative, which I successfully used during the last few years:
    : Use a TTabControl with its tabs created dynamically. For this to work you need to store the histogram info in an special object, which can also be stored in the Tabs property of the control. All you need to do is to redraw the histogram each time the user selects another tab.
    :
    I hadn't considered the TTabControl, but that's a good idea. I think I already tried having the application own the forms, but I'll check into that too. Thanks for the response.
Sign In or Register to comment.