|
The only way I can think of, is deriving a class from CIntList, and implementing a destructor there that frees the memory.
Don't know if that's the best option
|
|
|
|
|
Probably allocating on the heap single integers is not a good idea.
Maybe you need to revise your overall design.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Unless a NULL pointer is the equivalent to a boolean in their design.
|
|
|
|
|
?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
For each integer, if negatives, positives, and zero are valid data, there is no way to indicate if the integer should be used or ignored. Basically, an on/off switch to say ignore the integer at this index or data is valid at this index. The pointer can be used as the boolean flag. Valid pointer is "On", and NULL pointer is "Off".
|
|
|
|
|
OK. But this has nothing to do with my original point: sistematically allocating single integers (or, if you prefer, single boolean values) on the heap it is usually not (IMHO) a good idea. Dynamically memory allocation for built-in types is usually bad.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
piul wrote: Does anybody know if deleting pList frees all the allocated memory?
For each element created with new you need to call delete . Typically it looks like this: when you clear the list you iterate trough the list and call delete for each element in it and after that clear the list itself. Alternatively use a smart pointer[^] instead of a normal pointer -or- store elements instead of pointers (there is no need to store pointers in data containers).
Hope it helps.
/M
|
|
|
|
|
Hi,
Can we have our application as _UNICODE supported as well _MBCS supported?
I am in middle of a robust project, where we are using some third party sources. if i set my project to _UNICODE supported then it forces all the places where i am handling strings are to be wchar, TCHAR etc.,
can i make the same in some files, since it forces to make changes in third party sources.
To make UNICODE Supported i made changes like "In Project settings in preprocessor definitions i just added _UNICODE.
Also set startup with wWinMainCRTStartup.
Qns:
Can i support both of them ? if so How ?
Thanks in advance.
Thanks a lot
|
|
|
|
|
You are free to mix types all you want. It's up to you to keep track of the settings and make sure you're
using the right character types in the right places, and converting where necessary.
I personally would go all unicode and use other character types only where required, but that's just me.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: It's up to you
I'm betting that's the deal breaker part.
led mike
|
|
|
|
|
No it is not possible if you set your project _UNICODE in project settings, it will override _MBCS.
But i am here in position of converting a large project into UNICODE SUPPORTED.
Can i build that third party tool into a DLL and link them with my project ? Even though that also be defined _UNICODE.
Any Idea ? Get me out of this difficulty!.
Thanks
Thanks a lot
|
|
|
|
|
ganesa moorthy wrote: if you set your project _UNICODE in project settings, it will override _MBCS
Of course, but you need to understand how that affects your compilation.
Those are simply macros used with conditional compilation. The macros effect the
default char types in API function arguments and system structures. They also affect
the type of the tchar.h generic types like TCHAR.
You are still free to use specific types where necessary. For the affected Windows APIs,
you can call the specific APIs using the W and A suffixes where required. Same with Windows SDK
structures. In places where you need a specific char type, do NOT use the generic TCHAR - use the right type.
If you have third party code that requires a different character type then you need to deal with that by
converting your strings/char arrays to the correct type where necessary.
ganesa moorthy wrote: No it is not possible
Not true
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
It is really an useful hint!, i hope i can use it n my project.
Thanks
Thanks a lot
|
|
|
|
|
I'm dumping data in a listbox using a loop. I would like the listbox to display the data after each iteration as oppose to after the loop is over, how do I do that?
|
|
|
|
|
Threads?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I'm new to mfc...can you give me a kick start? also, would using a different control be better?
|
|
|
|
|
Please detail your problem. For instance, if your need to represent a very large amount of data, a virtual list control [^] maybe an option.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
If you do that in one single thread, the UI won't be able to process messages anymore (because the main thread is busy in your loop). This way, it will freeze and process the messages only when you exit the loop.
The way to solve this problem is either to create a worker thread that will send a message to the GUI each time a new item should be added in the list, or you can extract messages yourself from the queue and process them (GetMessage and DispatchMessage, see here[^] for some info).
|
|
|
|
|
Another option is after you add each string to the listbox, call the UpdateWindow:
m_pMyListBox->AddString(_T("Whatever string"));
m_pMyListBox->UpdateWindow();
The UpdateWindow bypasses the normal message loop, so you can update that way.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Karl,
UpdateWindow has solved my problem......
Thanks
How do I close this thread?
|
|
|
|
|
Glad I could be of assistance.
I don't know how you mark a thread as completed or resolved. Perhaps someone else knows.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
C++NewBe wrote: How do I close this thread?
Don't bother about, anyway you can modify the OP title (maybe adding [PROBLEM SOLVED] to the title).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
You cna use of CListCtrl instead CListBox that is better.
|
|
|
|
|
Exactly how does that solve the problem?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I think listctl is bette than listbox and I think its better to try with listctrl so I said ctrl is better and its not direct his answer.
|
|
|
|