From: Tyushkov Nikolay on

Is there a way to determine has my window opened child dialogs?

i.e. Main application window can open some child dialogs in response to
user's action: select color, file to open, folder to save, options
window etc. But this moment user can hide application (it supports
system-wide hotkey) or try to close it from tray menu. In this case
there is problem with services dialogs, application should hide or close
them too or ignore hide\exit command. But I have no idea how to know are
there such windows or not. What I can do?

--
Best regards, Nikolay Tyushkov
http://softvoile.com - Work with texts faster!

From: Vadim Zeitlin on
On Sun, 06 Apr 2008 10:59:24 +0300 Tyushkov Nikolay <wx(a)softvoile.com> wrote:

TN> Is there a way to determine has my window opened child dialogs?

Not easily... The only thing which comes to mind is to scan
wxTopLevelWindows list and check if there are any windows in it with your
top frame as parent.

Alternative idea would be to store the pointer to wxEventLoop::GetActive()
initially and compare its return value with the stored value later. At
least under MSW it will be different while a modal dialog is shown
(although probably not if it's a native dialog like e.g. an open file one).

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

From: Tyushkov Nikolay on

> TN> Is there a way to determine has my window opened child dialogs?
>
> Not easily... The only thing which comes to mind is to scan
> wxTopLevelWindows list and check if there are any windows in it with your
> top frame as parent.
>
Did you mean something like this?

wxWindowList::Node* node = wxTopLevelWindows.GetFirst();
while (node)
{
wxWindow* window = (wxWindow*)node->GetData();
if (window)
{
...
}
node = node->GetNext();
}

There is not much information about wxTopLevelWindows, but it seems (and
my experiments confirm) that, wxTopLevelWindows has no information about
native dialogs.

The code above returns information only about frames inherited from
wxFrame that I create directly (Option\About windows). But does not see
system dialogs i.e.

wxFileDialog dlg(this);
or
m_findDialog = new wxFindReplaceDialog( this, &m_findData, _("Find"),
wxFR_NOWHOLEWORD );


> Alternative idea would be to store the pointer to wxEventLoop::GetActive()
> initially and compare its return value with the stored value later. At
> least under MSW it will be different while a modal dialog is shown
> (although probably not if it's a native dialog like e.g. an open file one).
>
The same problem, it works only for wxWidgets window, does not work for
native dialogs:(


--
Best regards, Nikolay Tyushkov
http://softvoile.com - Work with texts faster!