cannot disable a wxStaticBox

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
daninz
In need of some credit
In need of some credit
Posts: 9
Joined: Thu Feb 27, 2014 11:16 am

cannot disable a wxStaticBox

Post by daninz » Sat Jul 08, 2017 10:35 am

I am on Windows, using wxWidgets-3.0.3.
I have a wxStaticBox which is the parent of the controls inside of it, and which is itself contained in a wxStaticBoxSizer, as this:

wxStaticBoxSizer *pSizer = new wxStaticBoxSizer(wxVERTICAL, etc...);
wxStaticBox* pStaticBox = pSizer ->GetStaticBox();
new wxCheckBox(pStaticBox, etc...);

In order to enable / disable the static box and all its child controls I do:

pStaticBox->Enable(true or false);

That works for all the children, but not for the static box itself, which always remains enabled (that is: is not grayed out). Is that a bug in my code, or in wxWidgets? Is it due to the fact that the wxStaticBox belongs to a wxStaticBoxSizer?

User avatar
doublemax
Moderator
Moderator
Posts: 14314
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: cannot disable a wxStaticBox

Post by doublemax » Sat Jul 08, 2017 8:14 pm

Isn't a wxStaticBox just a faint, grey line? How should it look when it's disabled?
Use the source, Luke!

daninz
In need of some credit
In need of some credit
Posts: 9
Joined: Thu Feb 27, 2014 11:16 am

Re: cannot disable a wxStaticBox

Post by daninz » Mon Jul 10, 2017 11:20 am

It is you again? I was happy someone had answered, and it turns out it is you again, making useless noises like usual. The other time (viewtopic.php?t=39164) you had 6000 posts, now thanks to your continuous blather which wastes everybody’s time around here you’ve accumulated over 11000.
What is indeed very ‘faint’ is your knowledge of this or seemingly any other subject. Have you never seen a native Windows dialog with a static box? Well, see one for the first time in your life then:
wxStaticBox.png
Native Windows dialogs showing an enabled and disabled static box.
wxStaticBox.png (9.94 KiB) Viewed 1592 times
YOU SPEND FAR TOO MUCH TIME TRAILING THE FORUMS IN A QUEST TO ACCUMULATE AS MANY POSTS AS POSSIBLE, FAR TOO MUCH TIME DOING THAT TO HAVE THE TIME TO DO ANY DEVELOPMENT AND GET ANY REAL KNOWLEDGE.
For the other ones: I’ve tried disabling a static box from a very simple dialog, and I see that finally a call to the native ::EnableWindow() is made, which succeeds. So, apparently, the box is reset to ‘enabled’ during event processing.
This appears to be a bug in wxWidgets. Anyone?

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2094
Joined: Sun Jan 03, 2010 5:45 pm

Re: cannot disable a wxStaticBox

Post by PB » Mon Jul 10, 2017 12:14 pm

daninz wrote:It is you again? I was happy someone had answered, and it turns out it is you again, making useless noises like usual. The other time (viewtopic.php?t=39164) you had 6000 posts, now thanks to your continuous blather which wastes everybody’s time around here you’ve accumulated over 11000.
Unlike you I have been "trailing the forums" for a long time and doublemax has been nothing but extremely helpful since I joined.
daninz wrote:What is indeed very ‘faint’ is your knowledge of this or seemingly any other subject. Have you never seen a native Windows dialog with a static box? Well, see one for the first time in your life then
Actually, a native static box is just a faint gray line in the recent versions of Microsoft Windows. Have you not seen any Windows version released in past few years? I myself don't like the new UI but it is hardly uncommon in 2017...
daninz wrote:YOU SPEND FAR TOO MUCH TIME TRAILING THE FORUMS IN A QUEST TO ACCUMULATE AS MANY POSTS AS POSSIBLE, FAR TOO MUCH TIME DOING THAT TO HAVE THE TIME TO DO ANY DEVELOPMENT AND GET ANY REAL KNOWLEDGE.
Please, what is with you and all the shouting and personal attacks. You come here, I suppose using your own dictionary "to beg for help" and throw a hissy fit when you do not immediatelly hear what you want to? I was suprised you were not told you are not welcome here after what you wrote back then. It was the first time seeing someone (mis)behaving like this here.
daninz wrote:This appears to be a bug in wxWidgets.
Obviously, there is not much you can do wrong when trying to disable a static box, so it indeed does look as a bug. Try to be useful for once and see where it goes wrong, create a proper bug report, hopefully with a fix attached. Even if you might not like to spend time and effort on debugging other people bugs, that's probably the only way you can give something back to a product you use for free, no strings attached...

daninz
In need of some credit
In need of some credit
Posts: 9
Joined: Thu Feb 27, 2014 11:16 am

Re: cannot disable a wxStaticBox

Post by daninz » Mon Jul 10, 2017 12:20 pm

You again, doublemax?

daninz
In need of some credit
In need of some credit
Posts: 9
Joined: Thu Feb 27, 2014 11:16 am

Re: cannot disable a wxStaticBox

Post by daninz » Mon Jul 10, 2017 12:26 pm

A call to the native EnableWindow(), from a native executable running on Windows 8.1, succeeds on disabling the static box, as shown on the image above.

And no, I will not make a bug report unless it is appears, depending on what real answers I get here, that this is indeed a bug. I don’t like wasting other people’s time, you see, with spurious reports.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2094
Joined: Sun Jan 03, 2010 5:45 pm

Re: cannot disable a wxStaticBox

Post by PB » Mon Jul 10, 2017 12:27 pm

I see, you are unable to maintain a proper conversation, opting to insult anyone instead. Good to know, so I don't keep wasting my time on you.

Hope you get your help somewhere, both with your programming and mental issues. Good luck.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2094
Joined: Sun Jan 03, 2010 5:45 pm

Re: cannot disable a wxStaticBox

Post by PB » Mon Jul 10, 2017 4:58 pm

Just for future reference, if anyone else gets interested in the issue...

I looked into MSW wxStaticBox code. On line 220 there is a comment
/*
We draw the static box ourselves because it's the only way to prevent it
from flickering horribly on resize (because everything inside the box is
erased twice: once when the box itself is repainted and second time when
the control inside it is repainted) without using WS_EX_TRANSPARENT style as
we used to do and which resulted in other problems.
*/
I just skimmed the code, but it seems that the window being disabled/enabled is not taken into account when painting the box label and frame. OTOH, the custom painting code in wxStaticBox::PaintForeground() should be executed only when the static box has a custom foreground color...

wxRadioBox is also affected by the issue, as it internally also uses wxStaticBox.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2094
Joined: Sun Jan 03, 2010 5:45 pm

Re: cannot disable a wxStaticBox

Post by PB » Tue Jul 11, 2017 10:33 am

I have dug a bit deeper into the issue. I was wrong and the issue actually has nothing to do with wxWidgets.

It is related to visual styles in MS Windows. If the application manifest has v6 common controls, the appearance of a disabled groupbox is same as for the enabled one. More information can be easily googled.

Plain Win32 code demonstrating the issue attached, the button appearance is a dead giveaway of whether the visual styles are used.
GroupBoxWin32.zip
(2.57 KiB) Downloaded 41 times

Post Reply