Pass a vector from a pushbutton in dialog class to ONDRAW () in the view.cpp

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

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

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.

Re: Pass a vector from a pushbutton in dialog class to ONDRAW () in the view.cpp

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.

Re: Pass a vector from a pushbutton in dialog class to ONDRAW () in the view.cpp

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...

Re: Pass a vector from a pushbutton in dialog class to ONDRAW () in the view.cpp

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

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

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