Board index » cppbuilder » GroupBox does not appear as grayed when disabled

GroupBox does not appear as grayed when disabled


2005-02-17 04:04:25 PM
cppbuilder25
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
 
 

Re:GroupBox does not appear as grayed when disabled

"Patrick FAURE" < XXXX@XXXXX.COM >wrote in message
Quote
When I set Groupbox->Enabled = false, Groupbox and its
components inside do not appear as grayed.

Why ?
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
 

Re:GroupBox does not appear as grayed when disabled

Quote
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.
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
 

{smallsort}

Re:GroupBox does not appear as grayed when disabled

"Vladimir Stefanovic" < XXXX@XXXXX.COM >wrote in message
Quote
Do you know the way to make TGroupBox caption
to look like it is disabled?
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
 

Re:GroupBox does not appear as grayed when disabled

This is really really great. Thanks a lot.
--
Best regards,
Vladimir Stefanovic
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Vladimir Stefanovic" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>Do you know the way to make TGroupBox caption
>to look like it is disabled?

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