It sounds like you need a windows hook.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms644959(v=vs.85).aspx#whgetmessagehook
with WH_GETMESSAGE you get to see the windows events being processed by the other application’s window, you could then wait for the WM_CLOSE to show up, and kill your dialog.
solved execute program while window handled mfc