GroupBox does not appear as grayed when disabled

GroupBox does not appear as grayed when disabled

Post by Patrick FA » Fri, 18 Feb 2005 17:04:25



Hello,

I have a groupbox and some components in it.

When I set Groupbox->Enabled = false, Groupbox and its components inside do not appear as grayed.

Why ?

Thank you for your answers.

Patrick
 
 
 

GroupBox does not appear as grayed when disabled

Post by Team » Sat, 19 Feb 2005 03:53:22


Because it is not supposed to. Container components, such as TGroupBox and
TPanel, do not become grey when they are disabled. Since their children are
not specifically disabled, they do not become grey, either.


Gambit

 
 
 

GroupBox does not appear as grayed when disabled

Post by Vladimir S » Sat, 19 Feb 2005 06:07:13

> Because it is not supposed to. Container components,

Do you know the way to make TGroupBox caption to
look like it is disabled? It's not simple changing the color
(which could be changed with published properties) -
it's a 3d look. Maybe one label with one color and second
label shifted right and down with second color.


--
Best regards,
Vladimir Stefanovic
 
 
 

GroupBox does not appear as grayed when disabled

Post by Team » Sat, 19 Feb 2005 07:34:07


TGroupBox is not set up to support that. To do what you are asking, you
will have to derive a new component from TGroupBox and override the default
drawing with your own manual drawing. For example:

class TMyGroupBox : public TGroupBox
{
protected:
virtual void __fastcall Paint();
public:
__fastcall TMyGroupBox(TComponent Owner) : TGroupBox(Owner) {}
};

void __fastcall TMyGroupBox::Paint()
{
int H, Flags;
TRect R;
AnsiString S;

Canvas->Font = Font;
H = Canvas->TextHeight("0");
R = Rect(0, (H / 2) - 1, Width, Height);
if( Ctl3D )
{
R.Left++;
R.Top++;
Canvas->Brush->Color = clBtnHighlight;
Canvas->FrameRect(R);
::OffsetRect(&R, -1, -1);
Canvas->Brush->Color = clBtnShadow;
}
else
Canvas->Brush->Color = clWindowFrame;
Canvas->FrameRect(R);

AnsiString S = Text;
if( S != "" )
{
if( !UseRightToLeftAlignment() )
R = Rect(8, 0, 0, H)
else
R = Rect(R.Right - Canvas->TextWidth(S) - 8, 0, 0, H);

Flags = DrawTextBiDiModeFlags(DT_SINGLELINE);
::DrawText(Canvas->Handle, S.c_str(), S.Length(), &R, Flags |
DT_CALCRECT);

Canvas->Brush->Color = Color;
if( !Enabled )
Canvas->Font->Color = clGrayText ;

::DrawText(Canvas->Handle, S.c_str(), S.Length(), &R, Flags);
}
}


Gambit
 
 
 

GroupBox does not appear as grayed when disabled

Post by Vladimir S » Sat, 19 Feb 2005 07:55:55

This is really really great. Thanks a lot.


--
Best regards,
Vladimir Stefanovic