Board index » cppbuilder » New Form + New Graph: how to

New Form + New Graph: how to

I am trying to disply n graphs, each in a new form.  So far, I can
create new forms on runtime.  But all the n graphs (a TGraph object) are
displayed in sequence in the very first form. Even worse, only the last
one in the set is visible in the first form.  The other forms contain no
graphs.  This is a version of the code.  Need yr help to tell me what is
wrong.  Thanx in advance.

Raad  (Yes,  I am a beginner in BCB3)

---------------------------------------------------------------------------------

In the prog.h file, I have:
            TGraph *GraphicsServer1;  // Declares a TGraph object

In the prog.cpp file, I have

    for(i=1;  i<n;  i++)
            {
            TGet_Histogram *Get_Histogram = new TGet_Histogram (this);
                // This gives a new form on runtime.
            GraphicsServer1->DataReset = 1;
            GraphicsServer1->NumSets = 1;  //One set of graphs for each
new form
            GraphicsServer1->AutoInc = 0;
            GraphicsServer1->ThisSet = 1; // The current set.
            Get_Histogram->Left += 100;   //to shif the new form to the
left
            Get_Histogram->Top += 50;   //to shif the new form down
            Get_Histogram->Show();
            GraphicsServer1->NumPoints = N; //  the number of points to
graph.

            for (j = 1; j < (GraphicsServer1->NumPoints); j++)
                    {
                    GraphicsServer1->ThisPoint = j;  // The current
point being graphed
                    GraphicsServer1->GraphData = float(h[i][j]); //Data
being graphed
                    }
            GraphicsServer1->DrawMode = 2;
            }

 

Re:New Form + New Graph: how to


Hi Raad,

Quote
Raad A. Saleh wrote:

> I am trying to disply n graphs, each in a new form.  So far, I can
> create new forms on runtime.  But all the n graphs (a TGraph object) are
> displayed in sequence in the very first form. Even worse, only the last

I think what you forget is setting the parent of the Chart. I'm
creating also dynamically charts on diffent TTTabSheets (nPage).
I'm handling a described below:

            TDBChart *dbChart = new TDBChart(nPage);
            if (dbChart)
            {
              dbChart->Name    = AnsiString("frmGraphChart")+ (Pages);
              dbChart->Parent  = nPage;

Regards,

Bart Huls

Quote
> one in the set is visible in the first form.  The other forms contain no
> graphs.  This is a version of the code.  Need yr help to tell me what is
> wrong.  Thanx in advance.

> Raad  (Yes,  I am a beginner in BCB3)

> ---------------------------------------------------------------------------------

> In the prog.h file, I have:
>             TGraph *GraphicsServer1;  // Declares a TGraph object

> In the prog.cpp file, I have

>     for(i=1;  i<n;  i++)
>             {
>             TGet_Histogram *Get_Histogram = new TGet_Histogram (this);
>                 // This gives a new form on runtime.
>             GraphicsServer1->DataReset = 1;
>             GraphicsServer1->NumSets = 1;  //One set of graphs for each
> new form
>             GraphicsServer1->AutoInc = 0;
>             GraphicsServer1->ThisSet = 1; // The current set.
>             Get_Histogram->Left += 100;   //to shif the new form to the
> left
>             Get_Histogram->Top += 50;   //to shif the new form down
>             Get_Histogram->Show();
>             GraphicsServer1->NumPoints = N; //  the number of points to
> graph.

>             for (j = 1; j < (GraphicsServer1->NumPoints); j++)
>                     {
>                     GraphicsServer1->ThisPoint = j;  // The current
> point being graphed
>                     GraphicsServer1->GraphData = float(h[i][j]); //Data
> being graphed
>                     }
>             GraphicsServer1->DrawMode = 2;
>             }

Other Threads