[SOLVED] Modal Frame

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
dcbdbis
Experienced Solver
Experienced Solver
Posts: 80
Joined: Sun Nov 24, 2013 9:49 pm
Location: Aurora, Colorado

[SOLVED] Modal Frame

Post by dcbdbis »

Good Afternoon,

I see and have uses both wxDialogs, and wxFrames.

Now I have an application where I need the Window to be modal, but be able to contain a menubar - which can't be dropped onto a wxDialog, but only a wxFrame.

In the not too distant past I've used "...MakeModal(true);" in my wxFrame's constructor. But it is no longer documented that I can see and appears to be slated to be removed entirely based upon one post I read. So I'd like to update my code to not use a function (::MakeModal(true)) that seems to be going the way of the dodo. Sooner or later Arch will start shipping wxWidgets 3.1.*....where this function (I read) will no longer be present and I'd like my applications to be portable to the new version of wxWidgets when Arch ships it.

So I need a mechanism to make a wxFrame modal, or a wxDialog menubar capable - without a lot of hoop-jumping like extensive class derivations, etc.

I've dropped a wxPanel onto a wxDialog - but am still prevented from putting a MenuBar on it.

C::B 17:12, Arch Linux, wxWidgets 3.0.4.


Suggestions please?


Thank You!


Dave
Last edited by dcbdbis on Fri Aug 23, 2019 12:21 am, edited 1 time in total.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Modal Frame

Post by doublemax »

Use the source, Luke!
dcbdbis
Experienced Solver
Experienced Solver
Posts: 80
Joined: Sun Nov 24, 2013 9:49 pm
Location: Aurora, Colorado

Re: Modal Frame

Post by dcbdbis »

Thank you for the response.

The wxWindowDisabler(wxWindow *winToSkip) may just be the right tool. I'm writing the code right now and expect to have it done soon. I'll write back in the next day or two how it works.

I appreciate the help with fleshing out my wxWindows knowledge..... The search term "wxFrame Modal" turned up nothing relevant before I posted.


Dave
dcbdbis
Experienced Solver
Experienced Solver
Posts: 80
Joined: Sun Nov 24, 2013 9:49 pm
Location: Aurora, Colorado

Re: [SOLVED] Modal Frame

Post by dcbdbis »

Well - the wxWindowDisabler worked as advertised - but as I create everything from the heap and not the stack - where to put the pointers to everything and how to destroy them became dicey with the interaction of the wxWindowDisabler and the wxFrame's destructor. And got worse if my user closed the child window and tried to reopen it.... The inter-relationships became a tad too complicated.

Works though....but might be better suited for objects created from the stack and not the heap.

What I ended up doing was a tad simpler - When I show the wxFrame, the very next line is "this->Enable(false)". Which disables the launching window in it's entirety. Then in the child window's destructor....I obtain the parent window's pointer, and then Enable the parent. For two-tier windows this works well and effectively makes the child window modal for all intents and purposes as there is nothing else to interact with except the desktop. Three or more tier child windows would require more extensive digital surgery to ensure proper relationships are maintained - and in the right order.

My issue is only two-tiered so it was simpler.

Thank you for the support!


Dave
Post Reply