April 2nd, 2004, 12:09 PM
How to make sure if a pointer is still good
I have 'A' dialog, which creates multiple modeless 'B' dialogs. I use GetDesktopWindow() as 'B' dialogs' parent for some reason.
'A' dialog saves pointers of 'B' dialogs to a CArray in order to do something when user closes 'A' dialog.
User can delete 'B' dialogs at any time before closing 'A' dialog. Since 'A' is not B's parent, I don't know how to notify 'A' dialog to remove the pointer from CArray if user deletes any of the 'B' dialogs.
However, so far, program works fine without any problems.
My question is
1) If user deleted a 'B' dialog, but its pointer still exists in 'A' dialogs' CArray. When 'A' dialog loops though CArray and got that pointer and use that to call some functions on B dialogs, will it cause any problems?
2) How do I make sure if the pointers on CArray are still good to use?
Any suggestions or comments are welcome,
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!