Loop through all wxFrames (and wxDialogs)? Topic is solved

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
Leffe108
In need of some credit
In need of some credit
Posts: 4
Joined: Fri Sep 16, 2011 8:41 pm

Loop through all wxFrames (and wxDialogs)?

Post 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
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Loop through all wxFrames (and wxDialogs)?

Post 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();
    }
Use the source, Luke!
Leffe108
In need of some credit
In need of some credit
Posts: 4
Joined: Fri Sep 16, 2011 8:41 pm

Re: Loop through all wxFrames (and wxDialogs)?

Post by Leffe108 »

Thank you, that solved my problem. Now I can implement my own way of finding top level windows of a certain kind.
Post Reply