View Issue Details

IDProjectCategoryView StatusLast Update
0027491LazarusLCLpublic2017-08-15 11:23
ReporterHoward Page-Clark Assigned ToMichl  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version1.1 (SVN) 
Target Version1.8 
Summary0027491: TGroupBox.Caption not greyed when disabled on Windows
DescriptionA disabled groupbox correctly disables its contained controls, but its Caption is not correspondingly greyed.
Steps To ReproduceOn Windows, set the Enabled property of any groupbox to False.
Additional InformationBlaazen on the forum has tested QT and Linux where the TGroupBox.Caption is greyed when Enabled=False.
TagsNo tags attached.
Fixed in Revisionr53906
LazTarget1.8
Widgetset
Attached Files

Relationships

related to 0031670 closedMichl Caption in TGroupBox with Enabled=False 

Activities

Zeljan Rikalo

2015-02-18 15:21

developer   ~0081214

It is greyed in Delphi ?

Bart Broersma

2015-02-18 16:57

developer   ~0081216

On Delphi 7 it does gray out the caption (with XP manifest).

Howard Page-Clark

2015-04-14 22:08

reporter   ~0082903

The problem seems to be a bug in recent versions of Windows comctrl.dll.

If you use a manifest (see attached maingroupbox.manifest) that removes dependency on (themed) comctrl the exe will show a GroupBox whose Caption greys out along with all its contained controls as expected. Seems you can have themes or properly functioning Groupbox captions, but not both.

If this is the case, a possible crude workaround would be to plant a TLabel over the groupbox Caption and draw it disabled... but this is just a poor hack.

Derit Agustin

2015-04-15 04:00

reporter  

Screenshot_4.png (36,687 bytes)   
Screenshot_4.png (36,687 bytes)   

CudaText man

2017-01-03 18:05

reporter   ~0097273

I cannot see how to do OK with grayed in WinAPI

var
  b: boolean;
procedure TForm1.Button1Click(Sender: TObject);
begin
  b:= not b;
  EnableWindow(GroupBox1.Handle, bool(b));
  GroupBox1.Invalidate;
end;

also dont give grayed Grpbox. So close as "cannot fix"..

Bart Broersma

2017-01-07 14:02

developer   ~0097349

> The problem seems to be a bug in recent versions of Windows comctrl.dll.
Any reference / link to that?

Janusz Tomczak

2017-01-07 19:50

reporter   ~0097360

Last edited: 2017-01-07 19:53

View 2 revisions

http://stackoverflow.com/questions/26481189/how-to-make-the-group-box-text-to-be-disabled-when-group-box-is-disabled

"Further to what Michael Walz said below, you could handle WM_CTLCOLOR in the parent and return the grey colour if the group box is disabled."

Bart Broersma

2017-01-07 22:53

developer   ~0097363

OK, resolving as not fixable then.

Michl

2017-01-09 18:03

developer   ~0097375

I've tested the issue for a while. As pointed out, this doesn't work, if themes enabled: https://msdn.microsoft.com/de-de/library/windows/desktop/bb787524(v=vs.85).aspx

But better then nothing, we can paint the caption ourself. So I made this workaround in revision 53906. Tested with/without themes, DPI aware on Win XP, 7 and 10.

Please test an report here, if I miss something.

Thank you

Michl

2017-01-09 18:04

developer  

GroupBoxTest.zip (3,750 bytes)

Janusz Tomczak

2017-01-09 19:00

reporter   ~0097377

I tested GroupBox, RadioGroup and CheckGroup on Windows 7 64bit. All works OK :)
Thank you Michl.

Bart Broersma

2017-01-10 00:25

developer   ~0097386

Should we really fix bugs in MS Windows?

Janusz Tomczak

2017-01-10 09:18

reporter   ~0097389

Although bug in MS Windows, but for the users it does not matter. They expect efficient program. Liability for defects always falls on the author of program.

Michl

2017-01-10 09:56

developer   ~0097390

Last edited: 2017-01-10 10:03

View 3 revisions

@Bart: I also thought on that question a longer while, before I commited the code.

Normally, I would call it a feature. But here the behaviour breaks the rule of other widgetsets (what is ok) but also breaks the own rule of design (what is not ok) (all other components, I tested, are grayed out).
The best thing would be a fix from MS side. But this bug is here since more then 7 years (http://stackoverflow.com/questions/1737108/how-do-i-set-the-font-and-color-for-a-group-box-caption-using-win32), so I don't see it.

There are a lot of workarounds in the widgetsets code to make things to work (what could be called a bug or inconsistency from widgetset).
To give Lazarus components consistency, I would work around bugs, as much as we can.

If there are problems with this workaround, please let me know. Now it's easy to reject the code.

[Edit]: wrong link, this is the correct one: https://groups.google.com/forum/#!topic/microsoft.public.vc.mfc/BNHCYsmydKc

wp

2017-01-10 11:26

developer   ~0097392

I like the fix. What's wrong with fixing a Windows bug?

There is some inconsistency in painting of the caption, though. Add a label to the groupbox and disable the groupbox - the disabled caption will not look the same as the disabled label.

Michl

2017-01-10 11:43

developer   ~0097394

Last edited: 2017-01-10 11:46

View 2 revisions

I've seen this too. Please have a look at the added example GroupBoxTest.zip. There you can see, the label has a wrong color, if it is disabled (maybe a new bugreport or we let it so?).

wp

2017-01-10 11:56

developer   ~0097395

Yes, and the disabled TLabel looks differently from a disabled TStaticText. Lots of inconsistencies...

TLabel is painted complety with LCL commands.

Isn't there a ThemeService/ThemeElementDetails for painting text which could be used for TLabel, TStaticText, TGroupbox caption?

Michl

2017-01-10 12:08

developer   ~0097396

This was my first attempt too, but no, there isn't. Have a look at themes.pas.

Michl

2017-01-10 13:54

developer   ~0097397

@wp: Yes, the label needs a redesign. It is wrong disabled on Win32, also on GTK2 and afaik all other widgetsets. The current disabled state is done for unthemed Win32 widgetset and used for all widgetsets.

I think, I will insert a TWSCustomLabel, so we can derive widgetset labels to fix some issues (we have some more for TLabel and Win32).

Michl

2017-01-10 17:22

developer   ~0097399

Last edited: 2017-01-10 17:47

View 2 revisions

First, I fixed the default disabled drawing for TStaticText, TLabel, TPanel and ThemeServices.

Tested on Windows XP, 7, 10, Linux Mint GKT2 and Linux Mint Qt4.
Revision 53912 - 53916. Hope it works for the other widgetsets too.

Please test an report, if I miss something.

wp

2017-01-10 19:53

developer   ~0097402

Looks good (Win 10), thank you

Issue History

Date Modified Username Field Change
2015-02-18 14:50 Howard Page-Clark New Issue
2015-02-18 15:21 Zeljan Rikalo Note Added: 0081214
2015-02-18 16:57 Bart Broersma Note Added: 0081216
2015-04-14 22:08 Howard Page-Clark Note Added: 0082903
2015-04-15 04:00 Derit Agustin File Added: Screenshot_4.png
2017-01-03 18:05 CudaText man Note Added: 0097273
2017-01-07 14:02 Bart Broersma Note Added: 0097349
2017-01-07 19:50 Janusz Tomczak Note Added: 0097360
2017-01-07 19:53 Janusz Tomczak Note Edited: 0097360 View Revisions
2017-01-07 22:53 Bart Broersma LazTarget => -
2017-01-07 22:53 Bart Broersma Note Added: 0097363
2017-01-07 22:53 Bart Broersma Status new => resolved
2017-01-07 22:53 Bart Broersma Resolution open => not fixable
2017-01-07 22:53 Bart Broersma Assigned To => Bart Broersma
2017-01-09 18:03 Michl LazTarget - => 1.8
2017-01-09 18:03 Michl Note Added: 0097375
2017-01-09 18:03 Michl Assigned To Bart Broersma => Michl
2017-01-09 18:03 Michl Status resolved => feedback
2017-01-09 18:03 Michl Target Version => 1.8
2017-01-09 18:04 Michl File Added: GroupBoxTest.zip
2017-01-09 18:05 Michl Resolution not fixable => reopened
2017-01-09 19:00 Janusz Tomczak Note Added: 0097377
2017-01-10 00:25 Bart Broersma Note Added: 0097386
2017-01-10 09:18 Janusz Tomczak Note Added: 0097389
2017-01-10 09:56 Michl Note Added: 0097390
2017-01-10 09:57 Michl Note Edited: 0097390 View Revisions
2017-01-10 10:03 Michl Note Edited: 0097390 View Revisions
2017-01-10 11:26 wp Note Added: 0097392
2017-01-10 11:43 Michl Note Added: 0097394
2017-01-10 11:46 Michl Note Edited: 0097394 View Revisions
2017-01-10 11:56 wp Note Added: 0097395
2017-01-10 12:08 Michl Note Added: 0097396
2017-01-10 13:54 Michl Note Added: 0097397
2017-01-10 17:22 Michl Note Added: 0097399
2017-01-10 17:47 Michl Note Edited: 0097399 View Revisions
2017-01-10 19:53 wp Note Added: 0097402
2017-02-03 17:46 Michl Status feedback => resolved
2017-02-03 17:46 Michl Resolution reopened => fixed
2017-04-17 12:05 Michl Relationship added related to 0031670
2017-04-17 14:10 Michl Fixed in Revision => r53906