How to detect if Modal dialog is open within application

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
hardik_shah
Earned a small fee
Earned a small fee
Posts: 16
Joined: Wed Apr 22, 2009 10:15 am
Location: India

How to detect if Modal dialog is open within application

Post by hardik_shah » Thu Sep 03, 2009 12:06 pm

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

TrV
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 630
Joined: Wed Jul 04, 2007 1:12 pm

Post by TrV » Thu Sep 03, 2009 1:13 pm


BenKey
In need of some credit
In need of some credit
Posts: 1
Joined: Mon Sep 28, 2015 11:37 pm

Re:

Post by BenKey » Mon Sep 28, 2015 11:44 pm

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.

User avatar
tierra
Site Admin
Site Admin
Posts: 1343
Joined: Sun Aug 29, 2004 7:14 pm
Location: Salt Lake City, Utah, USA
Contact:

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

Post by tierra » Tue Sep 29, 2015 2:39 am

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.

Post Reply