Loop through all wxFrames (and wxDialogs)?  [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.

Loop through all wxFrames (and wxDialogs)?

Postby Leffe108 » Sat Oct 29, 2011 10:00 pm

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
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)?  [SOLVED]

Postby doublemax » Sat Oct 29, 2011 10:24 pm

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!
User avatar
doublemax
Part Of The Furniture
Part Of The Furniture
 
Posts: 7177
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Loop through all wxFrames (and wxDialogs)?

Postby Leffe108 » Mon Oct 31, 2011 7:48 am

Thank you, that solved my problem. Now I can implement my own way of finding top level windows of a certain kind.
Leffe108
In need of some credit
In need of some credit
 
Posts: 4
Joined: Fri Sep 16, 2011 8:41 pm


Return to C++ Development

Who is online

Users browsing this forum: No registered users and 5 guests