Detecting modal dialogs in MFC

后端 未结 3 367
囚心锁ツ
囚心锁ツ 2021-01-13 20:53

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

3条回答
  •  广开言路
    2021-01-13 21:40

    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.

提交回复
热议问题