My small program is written on SDI. I have a CArray type data in my CProgramView.c and I would like to use it in one of my dialog box. Normally I do it within the dialog boxes but I dont understand the concept of SDI and dialog box.
In case of SDI the first call returns the application frame window which contains the active document, view etc. The active view is your current view where your array is implemented. What you need to do is implement a member function GetArray which gives access to your data.;)
However generaly it is not a good idea to have data in CView, use rather CDocument for your data and then access it using pFrame->GetActiveDocument()
But I still dont get the idea. Let me explain the task I need the program to do.
I have a coordinate display in CView (I use OnDraw to draw out the x-axis and y-axis) that allows user to use mouse pointer to pick out coordinate points on CView. Each points will be collected into an array (CArray). I made a struct that contents two elements x & y to store x and y coordinates.
Next, I have a dialog to list out the points. The dialog can be accessed from the menu.
I am new to VC++ but I have b/ground in C. How can use MFC to ease my coding?
1) Must I use struct so store x & y in CArray? Is there another way?
2) How can I use the CArray in my listing dialog? I tried to declare public variables in CView (CArray<mystruct,mystruct> myarray) but it doesnt allow me to declare.
In my opinion David (see bellow) proposed a simpler approach so in the CView member function where you construct the dialog pass the array to you dialog constructor. I recommend to use CPoint instead of your structure which stores x,y. The member function of the CView can be called via MFC message command.
1) Use CPoint in CArray to store points.
2) It is not a good idea to create public members in any class.
Depending on how you want to pass the array from the view to the dialog, you'll either need to create a new constructor for the dialog, or make one of its member variables public so that the view can assign a value to it directly.
In either case, the dialog will have a CArray* as a member variable. Once it has been assigned a value, it can be used as you like.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
I want to create a function that returns for each
element in something...
For example like an enum and callback function(for example:
EnumWindows and etc.) for each section in an INI file I want
my function call a callback function...OK?
And I have another question:
What is SDK?(Any article for beginners?)
javad_2005 wrote: What is SDK?(Any article for beginners?)
SDK stands for Software Development Kit. Any manufacturer can provide SDKs for its products. They consist of libraries of functions that perform particular tasks. You can use them in your own applications.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
Last Visit: 27-Nov-20 15:29 Last Update: 27-Nov-20 15:29