|
I am getting problem in deleting combobox pointer.
My snipset is,
CComboBox combo;
combo=new CComboBox;
combo=(CComboBox*)GetDlgItem(nID);
...
...// Its working fine
But
delete combo; // its not working
Pls suggest me a solution. and plz tell me whether i can do all the handling with Combobox object itself, without creating pointer.
Thanks in advance
|
|
|
|
|
from the MSDN for GetDlgItem:
The returned pointer may be temporary and should not be stored for later use.
so, don't overwrite the result of the 'new'. store it away somewhere safe, and delete that. don't delete the result of GetDlgItem.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
i am not deleting the result of GetDlgItem.
still not working
|
|
|
|
|
GetDlgItem returns you a pointer. And you use this pointer to replace the previous pointer that was in combo.
So, when you call delete, you try to delete the pointer which is in the combo variable which is the pointer retrieved from GetDlgItem
|
|
|
|
|
|
combo is not a pointer yet you are trying to use the new operator on it.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
CComboBox combo;<br />
combo=new CComboBox;<br />
combo=(CComboBox*)GetDlgItem(nID);
That snippet should not even compile - post the real code and maybe we can help you. If you allocate a CComboBox object, you should not be overwriting that pointer before trying to delete it.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
sorry i have made a mistake in giving the snipset.
it is like
CComboBox* combo;
combo=new CComboBox;
combo=(CComboBox*)GetDlgItem(nID);
...
...// Its working fine
But
delete combo; // its not working
|
|
|
|
|
damn, you have mud on your eyes !!!
Aryan S wrote: combo=new CComboBox;
combo=(CComboBox*)GetDlgItem(nID);
you assign combo twice... so you are not delete ing what you previously new ed
TOXCCT >>> GEII power [toxcct][VisualCalc 2.24][3.0 soon...]
|
|
|
|
|
Why are you even bothering with new and delete ? If you already have a combobox control on the dialog, you should also have a CComboBox member variable associated with that control.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
don't change the value of combo after the initialization with new , and delete will work well.
If you want to destroy the object use combo->DestroyWindow() , and then call delete combo; .
Hope this help,
Bye
Have a nice code day
|
|
|
|
|
|
|
Hi,
I need to modify some strings within the string table of the resources of an MFC/EXE and a MFC/DLL without recompiling them because I don't have the corresponding source code.
If I open each EXE or DLL as resources with Visual Studio 6, I can modify the string table and save the EXE or DLL file.
=> Is it dangerous?
=> How are the resources stored within the binary files? Is the string size fixed?
Thanks and regards
Pascal
Grenoble/FRANCE
|
|
|
|
|
I believe you can safely make those changes as long as the new string is the same size as the old string. It do not know the repercussions if their size differs. You'll just have to try it and see. Let us know what you find.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
In fact, I have set a string larger than the previous one and it works!
But it is not because it works this time that it will always work... :->
Pascal
|
|
|
|
|
What are you using to make the change? UpdateResource() may indeed have provisions for shrinking/growing the resource area of a file.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
I launch Visual Studio 6.0.
I open my .exe file as "resources".
I change the string table values.
I save (Ctrl+S).
Then, maybe VS calls UpdateResource() in this case?
Thanks and regards
Pascal
|
|
|
|
|
|
The size of the string only really matters if you are doing the changes directly in the binary. If you use the resource updating functions, you can change the size of the string.
Of course, if the code of the executable expects the string in a certain format or length...
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Of course, if the code of the executable expects the string in a certain format or length...
This would certainly be my primary concern if making the strings longer.
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
|
I am porting a windows application to Linux and would like to keep a portion of the windows code that uses WSAAsyncSelect the same. I can implement this using a busy while loop checking select/FD_ISSET on my sockets. But this seems inefficient. Is there a linux equivalent to this function?
|
|
|
|
|
I just found <sys epoll.h="">. Need to get better with my google queries
|
|
|
|
|
Jnewg5 wrote: I just found . Need to get better with my google queries
meant to include "sys/epoll.h"
|
|
|
|