Re: Pass a vector from a pushbutton in dialog class to ONDRAW () in the view.cpp
Why are you declaring vectors in your dialog? Stop it. As I said before, it's really clear you're missing some fundamental concepts, more than can be introduced and explained in forum posts. Stop what you're doing. You're over your head. Spend some time learning how MFC, doc/view and dialogs work, and spend some time learning the basics of OOP. You can't learn this stuff by guessing and trial and error. It's too complicated.
Re: Pass a vector from a pushbutton in dialog class to ONDRAW () in the view.cpp
Quote:
Originally Posted by
tarkes
For calculation puroposes i need values and so do i store it in vector format.. I have attached a screen shot as weel as i have quoted the code. Please have a look.
That doesn't address the issue about the memory leak.
How many times is OnPlot() called? Multiply that by 500 (or more) bytes, and that is how much total memory is leaked by that function. So if the function is called 1,000 times, that's 500,000 bytes leaked. Sooner or later, your app will die due to the memory leakage.
There is no need to be using new[] in that OnPlot() function. Either declare a regular array, or use vector<TCHAR>. It makes no sense to use vector everywhere and then not use it for what vector was designed for.
Regards,
Paul McKenzie
Re: Pass a vector from a pushbutton in dialog class to ONDRAW () in the view.cpp
pDOC is a pointer as declared
Code:
CContourPlotDoc *pDoc;
in colourdlg.h
I have attached the screen shot of all files existing..Please kindly have a look
Re: Pass a vector from a pushbutton in dialog class to ONDRAW () in the view.cpp
Quote:
Originally Posted by
Paul McKenzie
That doesn't address the issue about the memory leak.
How many times is OnPlot() called? Multiply that by 500 (or more) bytes, and that is how much total memory is leaked by that function. So if the function is called 1,000 times, that's 500,000 bytes leaked. Sooner or later, your app will die due to the memory leakage.
There is no need to be using new[] in that OnPlot() function. Either declare a regular array, or use vector<TCHAR>. It makes no sense to use vector everywhere and then not use it for what vector was designed for.
Regards,
Paul McKenzie
ONPLOT() is not called repeatedly. On pressing the PLOT button in a dialog box designed it starts executing the codes writen to generate the RGB vector.
Further I would like to make a note that when i remove this line
Code:
pDoc->RGBVector.push_back(temp);
everything works fine..Loops and all run fine.. Nothing gets stuck ..
Re: Pass a vector from a pushbutton in dialog class to ONDRAW () in the view.cpp
Quote:
Originally Posted by
tarkes
pDOC is a pointer as declared
Code:
CContourPlotDoc *pDoc;
in colourdlg.h
And how and where is it initialized?
Quote:
Originally Posted by
tarkes
I have attached the screen shot of all files existing..Please kindly have a look
Please, don't attach such types of screenshots.
Attach the appropriate code snippets instead! And son'tr forget using Code tags and proper indentations.
Re: Pass a vector from a pushbutton in dialog class to ONDRAW () in the view.cpp
Quote:
Originally Posted by
VictorN
And how and where is it initialized?
Please, don't attach such types of screenshots.
Attach the appropriate code snippets instead! And son'tr forget using Code tags and proper indentations.
Initialize ?? I couldnot get it. I declared that pointer so as to have acess the vectors in Dialog class and assign the values to the vectors
Re: Pass a vector from a pushbutton in dialog class to ONDRAW () in the view.cpp
Quote:
Originally Posted by
tarkes
ONPLOT() is not called repeatedly. On pressing the PLOT button in a dialog box designed it starts executing the codes writen to generate the RGB vector.
Again, how does this address the memory leak in that function??. It doesn't matter if it's called once or a million times, the function has a memory leak, and I told you how to fix it.
Regards,
Paul McKenzie
Re: Pass a vector from a pushbutton in dialog class to ONDRAW () in the view.cpp
Quote:
Originally Posted by
Paul McKenzie
Again, how does this address the memory leak in that function??. It doesn't matter if it's called once or a million times, the function has a memory leak, and I told you how to fix it.
Regards,
Paul McKenzie
Ok arrays may be will help out
Re: Pass a vector from a pushbutton in dialog class to ONDRAW () in the view.cpp
Quote:
Originally Posted by
tarkes
Initialize ?? I couldnot get it. I declared that pointer so as to have acess the vectors in Dialog class and assign the values to the vectors
Maybe this is the main point. Declaring a pointer never means you're allowed to use it uninitialized. Declaration doesn't do any magic, it just allocates some memory and instructs compiler about what type it is. You must fill it with the address of your doc class before first use. Man, seems GCDEF is right, and you have to get back learning pointers before doing anything real.
Re: Pass a vector from a pushbutton in dialog class to ONDRAW () in the view.cpp
Basically I am related to mechanical. I am not so big expert in computer science field that i will understand everything in one shot. I have done C++ but for simple programs. Here in visual C++ many classes, handles and I dont know hell lot of functions are available..
I really getting mad. Some part i could understand.. Some part i get confused where to write...
i am using to for my some research purpose..
Re: Pass a vector from a pushbutton in dialog class to ONDRAW () in the view.cpp
Quote:
Originally Posted by
tarkes
Basically I am related to mechanical. I am not so big expert in computer science field that i will understand everything in one shot. I have done C++ but for simple programs. Here in visual C++ many classes, handles and I dont know hell lot of functions are available..
I really getting mad. Some part i could understand.. Some part i get confused where to write...
i am using to for my some research purpose..
And you're going to keep getting mad because you're trying to do too much too soon. There is a HUGE learning curve with C++, MFC, OOP and Windows programming, especially when you try to do them all at once as you are. I would expect it to take months to learn all you need to learn to do what you're trying to do. If you're expecting to bang this out in a day or two, you need to adjust your expectations.
Re: Pass a vector from a pushbutton in dialog class to ONDRAW () in the view.cpp
Quote:
Originally Posted by
tarkes
Basically I am related to mechanical. I am not so big expert in computer science field that i will understand everything in one shot. I have done C++ but for simple programs. Here in visual C++ many classes, handles and I dont know hell lot of functions are available..
I really getting mad. Some part i could understand.. Some part i get confused where to write...
i am using to for my some research purpose..
Then why did you ignore to learn something using MSDN samples I referred to in one of my previous posts?
It is what you had to begin with (just after reading the corresponding documentation)
Re: Pass a vector from a pushbutton in dialog class to ONDRAW () in the view.cpp
Quote:
Originally Posted by
GCDEF
And you're going to keep getting mad because you're trying to do too much too soon. There is a HUGE learning curve with C++, MFC, OOP and Windows programming, especially when you try to do them all at once as you are. I would expect it to take months to learn all you need to learn to do what you're trying to do. If you're expecting to bang this out in a day or two, you need to adjust your expectations.
Can you suggest me some good books or tutorials where i could understand. I followed up some books like Visual C++ in 21 Days and some such books.. There I just find how to add something and plot something .. but i dont find as simple i am looking for..
MSDN tutorials are not working. May be that could have been benficiary but bad luck...its not working in this country
Re: Pass a vector from a pushbutton in dialog class to ONDRAW () in the view.cpp
Quote:
Originally Posted by
VictorN
The why did you ignore to learn something using MSDN samples I referred to in one of my previous posts?
It is what you had to begin with (just after reading the corresponding documentation)
Sir Badluck that website u sent i found those links earlier from someothe websites. Its not working in India .. I gues its working only in US
Re: Pass a vector from a pushbutton in dialog class to ONDRAW () in the view.cpp
Quote:
Originally Posted by
tarkes
Sir Badluck that website u sent i found those links earlier from someothe websites. Its not working in India .. I gues its working only in US
Define "not working"