How can I programmatically detect if my MFC application currently is displaying a modal dialog or property sheet? Currently I\'m using the following, but I feel that the cod
Have you tried CWnd::GetLastActivePopup?
I haven't tested this to see if it'll work for modal dialogs only.
Edit 1: According to Raymond Chen, GetLastActivePopup
should return the current active modal dialog.
Edit 2: Perhaps another method to retrieve the current modal window would be to modify your code to check for a disabled parent/owner - modal dialogs should always disable their owner before displaying.