Page 1 of 1

Loop through all wxFrames (and wxDialogs)?

Posted: Sat Oct 29, 2011 10:00 pm
by Leffe108
I wonder how can I loop through all wxFrames and wxDialogs in my application?

I want to do this in order to find windows by their (base) class type and when the window is found possible also examine some of its public properties. Eg. figure out if a property window for a certain object is open or not.

Can I perhaps access some container that can be used to iterate over all top level windows? (I've tried to search the API + google but have not found anything)


Edit: I'm using wxWidgets 2.9.2

Re: Loop through all wxFrames (and wxDialogs)?

Posted: Sat Oct 29, 2011 10:24 pm
by doublemax
There is no API for it, but there is a global variable "wxTopLevelWindows" which is a list that contains the pointers to all wxTopLevelWindows.

Code: Select all

    wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst();
    while (node)
    {
        wxWindow* win = node->GetData();
        // do something with "win"

        node = node->GetNext();
    }

Re: Loop through all wxFrames (and wxDialogs)?

Posted: Mon Oct 31, 2011 7:48 am
by Leffe108
Thank you, that solved my problem. Now I can implement my own way of finding top level windows of a certain kind.