Page 1 of 1

How to detect if Modal dialog is open within application

Posted: Thu Sep 03, 2009 12:06 pm
by hardik_shah
Hi,

Does anyone have an idea if there is any wxWidgets way to detect whether any Modal Dialog box is open within the scope of the application?

While receiving certain events, I need to detect if there is any Modal dialog box (either custom Modal or File Open/File Save etc. Modal dialogs) are open or not.

Does wxWidgets provide a way to detect this? Or if someone even know any Mac specific API for this, that will help as well.

Thanks,
Hardik

Posted: Thu Sep 03, 2009 1:13 pm
by TrV

Re:

Posted: Mon Sep 28, 2015 11:44 pm
by BenKey
Can you please give a little more information? Posting a link to the wxWindow Class Reference documentation does not an answer to this question make. I do not see a IsDialogActive or IsFrameActive function in that class. I see a HasFocus function but I do not see how that can be used to answer the question of how to determine if a dialog box is open.

You need to provide a great deal more information.

Re: How to detect if Modal dialog is open within application

Posted: Tue Sep 29, 2015 2:39 am
by tierra
The best idea I could maybe come up with is to use FindFocus(), and check if the containing top level window is a wxDialog, and checking that for wxDialog::IsModal().

That sounds like a fairly unreliable solution though (just because it's modal doesn't mean it necessarily has focus), and it would be better to hear why you need this because it's not something most applications need, and there's likely a much better approach to your problem, whatever it is.

If you still want to take that approach though, I'd highly recommend adding your own application-wide state (likely in your derived wxApp class) that you set whenever you open a modal dialog in your application. Just because wxWidgets doesn't provide it doesn't mean you can't still handle it yourself.