Click here to Skip to main content
15,900,110 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to auto put string into edit control and press button on web page? Pin
blackwolf123334-Jul-11 18:53
blackwolf123334-Jul-11 18:53 
QuestionSOLVED Bitmap histogram - size does matter ! [modified] Pin
Vaclav_17-Jun-08 12:40
Vaclav_17-Jun-08 12:40 
AnswerRe: Bitmap histogram - size does matter ! Pin
Mark Salsbery17-Jun-08 13:42
Mark Salsbery17-Jun-08 13:42 
GeneralRe: Bitmap histogram - size does matter ! Pin
Vaclav_17-Jun-08 15:05
Vaclav_17-Jun-08 15:05 
GeneralRe: Bitmap histogram - size does matter ! Pin
Mark Salsbery18-Jun-08 6:03
Mark Salsbery18-Jun-08 6:03 
GeneralRe: Bitmap histogram - size does matter ! Pin
Vaclav_18-Jun-08 7:04
Vaclav_18-Jun-08 7:04 
GeneralRe: Bitmap histogram - size does matter ! Pin
Mark Salsbery18-Jun-08 10:58
Mark Salsbery18-Jun-08 10:58 
QuestionMFC CListCtrl Memory management Pin
Psyinx17-Jun-08 9:52
Psyinx17-Jun-08 9:52 
Hi there,

I'm really stumped with the memory re-allocation with a CListCtrl in MFC after using the SetItemData function
and was wondering if any of you could help me out.
Here goes:

I have a class MyClassX which I instantiate using MyClassX * myClassInst = new MyClassX();
I add this instance to a CListCtrl myListCtrl using the following: myListCtrl.SetItemData( lineX, (DWORD)myClassInst );
This is all well and fine and I am able to retrieve the data and work with it, all happiness, however here is my problem.

When the time comes to delete this class, I step through each entry in the list pulling out its data item with
MyClassX * tmpClassX = (MyClassX*)myListCtrl.GetItemData(index);) and subsequently call delete tmpClassX; which deletes the instance no problem.... however, closer examination on the memory tells me otherwise. Even though the destructor of the MyClassX was called, and the instance no longer exists, the memory allocated for the class does not free.

I've tested the deletion process without adding the class to the CListCtrl and my memory is always reclaimed, however once adding the data to the list, the memory is never freed. (After first physically deleting the created classes, then calling DeleteAllItems on the list).

This is very puzzling to me and I'm beginning to wonder if some malloc operation goes on inside the CListCtrl once the SetItemData is called, but the memory is never de-allocated once cleared.

Should I create a "light weight" struct with a (void *) pointer and an index and just add this struct to the list rather?
Should I override the DeleteAllItems call in a custom list?
I’m absolutely puzzled!!Confused | :confused:
Thanks in advance...
QuestionRe: MFC CListCtrl Memory management Pin
David Crow17-Jun-08 10:05
David Crow17-Jun-08 10:05 
AnswerRe: MFC CListCtrl Memory management Pin
Psyinx17-Jun-08 11:42
Psyinx17-Jun-08 11:42 
QuestionRe: MFC CListCtrl Memory management Pin
David Crow17-Jun-08 16:37
David Crow17-Jun-08 16:37 
AnswerRe: MFC CListCtrl Memory management Pin
bonkers12318-Jun-08 1:02
bonkers12318-Jun-08 1:02 
QuestionRe: MFC CListCtrl Memory management Pin
David Crow18-Jun-08 2:26
David Crow18-Jun-08 2:26 
AnswerRe: MFC CListCtrl Memory management Pin
bonkers12318-Jun-08 5:08
bonkers12318-Jun-08 5:08 
GeneralRe: MFC CListCtrl Memory management Pin
David Crow18-Jun-08 5:15
David Crow18-Jun-08 5:15 
GeneralRe: MFC CListCtrl Memory management Pin
bonkers12318-Jun-08 22:23
bonkers12318-Jun-08 22:23 
QuestionHow to get VC++ version installed? Pin
ben217-Jun-08 9:28
ben217-Jun-08 9:28 
AnswerRe: How to get VC++ version installed? Pin
ThatsAlok18-Jun-08 2:51
ThatsAlok18-Jun-08 2:51 
Question"extern inline" in C header file Pin
crewchill17-Jun-08 8:27
crewchill17-Jun-08 8:27 
AnswerRe: "extern inline" in C header file Pin
Joe Woodbury17-Jun-08 15:02
professionalJoe Woodbury17-Jun-08 15:02 
AnswerRe: "extern inline" in C header file Pin
Nibu babu thomas17-Jun-08 17:11
Nibu babu thomas17-Jun-08 17:11 
Questionhow to change the back ground color of Label at runtime Pin
ramnathrn17-Jun-08 8:16
ramnathrn17-Jun-08 8:16 
QuestionRe: how to change the back ground color of Label at runtime Pin
David Crow17-Jun-08 8:51
David Crow17-Jun-08 8:51 
QuestionC program Pin
Subhankar17-Jun-08 7:40
Subhankar17-Jun-08 7:40 
AnswerRe: C program Pin
Alan Balkany17-Jun-08 8:26
Alan Balkany17-Jun-08 8:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.