Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
can't get MFC to communicate with itself
Im having real problems getting MFC to communicate with itself. It seems that everything I define in the document is forgotten when the view file is run.
All I want a function to do is to draw a line based on XY co ordinates held in an array.
class CLine : public CObject
void RandomCoOrd(void);// set the genes
void DrawLine(CDC* pDC) const;//draw the line
//int SectionLength(int m_XYCoOrds);//returns length of section
//int ncrosses(int m_XYCoOrds);//gets the number of lines crossed
The Coordinates are random numbers that are stored in the XYCoOrds Array. Where [i] is X and [i] is Y. for each point. A line should then be drawn to the next point i.e. [i+1], [i+1]
There will be 10 such objects of this type with the names line1, line2 etc.
Whenever a new document is initialised I want the lines to be different so I have put the following into the doc.cpp file
// TODO: add reinitialization code here
The randomCoOrd function fills the XY array.
Now all I want to do is to draw the line. I have defined a menu item called line1 to show Line1. Add put the following code into it:
CThursDoc* pDoc = GetDocument();
CDC* pDC = GetDC ();
I thought that GetDocument was meant to let view see all the objects created in the DOC file. When I try and run this however it says that Lines1 is an undeclared identifier. PLEASE tell me where I am going wrong, I am literally tearing my hair out over this one.
0 · ·