Send message to a non-existent window
Posted on 2006-06-05
In my application, Dialog "A" can indirectly create Dialog "B". In a perfect situation, Dialog "A" will wait for Dialog "B" to signal completion by sending some completion information via PostMessage. However, if the user insists on exiting from Dialog "A" without first cleaning up Dialog "B", then Dialog "B", upon completion, will be Posting a message into the ether.
1. Is is OK to post a message to a handle that is no longer in existence.
2. How often will a new window get the same HWND as a previous window. I'm concerned that since Windows maintains some sort of HWND table(I'm guessing), the addresses are re-used often.
3. Is there a better way to do what I want to do here. Dialog "B" might be creating a new record in a database file, and Dialog "A", assuming it is still in existence, should not only know that Dialog "B" has completed, but should also know the location of the new record, and come back into focus. If the user has cancelled Dialog "A", it does not necessarily invalidate the action of Dialog "B", it just renders the message from Dialog "B" moot. I intend to warn the user, but, a willy nilly user could potentially create 4 or 5 Dialog "Bs" this way, and I don't want to put the onus on him/her to clean up the mess before closing Dialog "A".
Thanks in advance, Rick