how to plot data from an array in a new frame.

how can i plot an array filled with integer values, in a new frame, on clicking open  from the file menu?
i wish to open a new frame when i click File->open.
in the new frame , how can i plot the data in the array?

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

bdunz19Connect With a Mentor Commented:
Ok, so I think the problem you are having is that the data is cahnging in all the child frames when you open a new data file, am I hitting the mark?

What you should do or rather need to do, is pass the new data to your child frame as a copy, rather than a pointer. This way, each frame will have it's own unique copy of data that will not change (unless you want it to!). So, I personally, would take the route of creating a function like SetDataArray(float *array, int size) in your CChildFrame class. When you create your child frame you can then just call this function to copy the data into your child frame, ie:

CMainFrame* pFrame = STATIC_DOWNCAST(CMainFrame, m_pMainWnd);
// create a new MDI child window
CChildCustList* pChild = (CChildCustList*)pFrame->CreateNewChild(
RUNTIME_CLASS(CChildFrame), IDR_csbillserviceTYPE, m_hMDIMenu, m_hMDIAccel);
// Now pass your data to the class
((CChildFrame*)pChild)->SetDataArray(array, arraysize);

Then pass that array and the array size to your view the same way:

void CChildFrame::SetDataArray(float *array, int size)
  m_wndView.SetDataArray(array, size); // Pass this data on to your view class.

Once you get it there you need to have a member of your child view class that is a float pointer. Then do something like the following:

void CChildView::SetDataArray(float *array, int size)
  m_array = new float[size]; // Allocate the correct size for your array.

  for(int i = 0; i < size; i++)
    m_array[i] = array[i]; // Copy the array

  // Now we have our own class member that is a perfect copy of the array data.

Let me know how this works,
bdunz19Connect With a Mentor Commented:
Hi nikhil,

You are asking, i'm supposing, as to how to graph the data you have in a new frame window, correct? Are you looking for bar graphs or what? You run out of options as you are using an array of integers that is only 1 dimensional.

Anyway, what you would want to do in any situation is create a new CWnd that you would draw yourself and make it a child of your frame view. Then you would pass the array to your new CWnd control and paint the control accordingly (OnPaint()). Once you reply with more specifics I can help your with some code.

Nikhilesh_KAuthor Commented:
i m using an array on floating numbers. i have a num.csv file which has the array of integer stored in A1 to A400, reading from the csv file is no problem, but getting it on a new frame is the main problem. i get the data in an array num[400] in the OnFileOpen() , plotting the data in is also not a problem, i did it in OnDraw() class. what i want to try is to plot the same in a new frame. so that another wave can be plot in some other frame. something like multiple frames in the same window.
i hope you are getting what i m trying to say.

All Courses

From novice to tech pro — start learning today.