wxButton on wxFrame IsEnabled() weirdness.

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
spiffy
Earned a small fee
Earned a small fee
Posts: 15
Joined: Wed Dec 13, 2017 6:24 pm

wxButton on wxFrame IsEnabled() weirdness.

Post by spiffy »

Hi:

Setup:
> Windows 7 and 8.1 x64
> Visual Studio 2013 (v12)
> wxWidgets 3.1 (x86)
> Link Type: static

Scenario/Problem:
I have a wxButton (myButton) on a wxFrame as a parent.
myButton has been set to disabled.
I do the following to enable the button after some processing:

Code: Select all

myButton.Enable(true);
myButton.SetBitmap(someBitmap);
myButton.SetBitmapDisabled(wxBitmap());
// force image update...
myButton.Refresh();
myButton.Update();
A wxTimer will soon check the state of myButton as a flag for other processing with:

Code: Select all

if (!myButton.IsEnabled()){/*do something*/}
My problem is that *sometimes* the parent of myButton (the wxFrame) is reporting as being disabled in the IsEnabled() check. This causes myButton to always report as disabled, even when I have set it back to enabled (which causes unwanted problems in the program).

Why would the wxFrame (parent of myButton) have been set to disabled at all? Is this a result of the calls I made above for bitmap changes and refresh/update? Or is there something else that happens normally with wxFrames internally that causes them to go disabled? I don't have any calls in my code to disable the wxFrame directly.

Current Solution:
As suggested in the docs, I'm using IsThisEnabled() instead of IsEnabled().

My goal with this post is just to understand why the wxFrame is showing as disabled.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxButton on wxFrame IsEnabled() weirdness.

Post by doublemax »

The only situation i could think of is when you display a modal dialog (e.g. a progress dialog). Then its parent will get disabled.
Use the source, Luke!
spiffy
Earned a small fee
Earned a small fee
Posts: 15
Joined: Wed Dec 13, 2017 6:24 pm

Re: wxButton on wxFrame IsEnabled() weirdness.

Post by spiffy »

doublemax wrote:The only situation i could think of is when you display a modal dialog (e.g. a progress dialog). Then its parent will get disabled.
I do use modal windows in this program but not during any of these related operations and not from anywhere on this wxFrame (completely different part of the program). The parent wxFrame in question does have the wxSTAY_ON_TOP style. Not sure if that would matter or not.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxButton on wxFrame IsEnabled() weirdness.

Post by doublemax »

In that case you have to narrow down the "sometimes" a bit more.
Use the source, Luke!
Post Reply