delete against an object, whose type has a destructor will call the 'vector deleting destructor', which will call the destructor for each element.
The problem is the number of elements.
When new is called on a type with a destructor:
1. malloc a block large enough to hold the reqested # of elements, the actual block size will be rounded up to some grain size.
2. store the actual block size (bytes) with the block for free().
3. store the requested # of elements with the block so delete can iterate over them and call ~().
When you call delete on a different (sized) type the # of elements stored with the block will be wrong and you will either call ~() on too few or too many elements.
If too few then you could have a memory leak if the destructor frees resources.
If too many then you corrupt the heap.
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
i try to write large text in to CComboBox field, but the max text length is limited by the CComboBox width !!!
But i need to imput larger text as the width of the combo box, when i write my text, the cursor moves to the right!!??
If i read large string from a file, this can be showed in the combo box, only if i try to write them by my self its limited!?
Can any one help me how to solve this??
I am useing worker thread in Dialog base Application.In Dialog I have a Static Control and Button.I try to set some values in Static Control.I have got some GUI Error application and CtlColor color change auto.As well as Control move from fixed position.I am doing like this
Never never access GUI elements in another thread than the GUI thread. This is a recipe for disaster. One way to solve your problem is instead to access the static control directly in your thread, you simply send a user defined message to your dialog. In the handler of this message, you update your control. This way, this is the UI thread that still accesses the control. More info and examples here[^]
If you would have taken the time to look at the article I linked to, you could see that there's an example in the section "Worker threads and the GUI II: Don't touch the GUI".
It's been a while that you are posting questions about threads and you still miss some basic concepts. Don't you think it could be interesting for you to read some good article (like the one I linked to you) about the subject ? Otherwise, you'll come asking questions here again and again and never really learn how to do it the proper way.
By touch I mean manipulating any UI related element.
Eugen Podsypalnikov wrote:
it is working
Did you test it ? If it works, you are lucky. But it is any way an extremly bad practice. I suggest you read the section "Worker threads and the GUI II: Don't touch the GUI" in the article I mentioned earlier to have a bit more information.
newCCtrlDrawContext(new CClientDC(&m_cwndStatic), // first par
cStaticRect)); // second par