Board index » delphi » Disabled GroupBox

Disabled GroupBox

I have a TGroupBox on my form with a number of controls
on it.  If I set Enabled to false on the GroupBox, the controls
are indeed not longer usable, but they don't grey out.
So I go around disabling all the controls, and the now
grey out.  However the caption on the GroupBox still
won't grey.

Any ideas?

 

Re:Disabled GroupBox


I think you are better off using some free third party group box component
that gives this functionality out of the box. Just search on Torry's pages.

Vikram

Quote
"Don Payette" <Nob...@nowhere.com> wrote in message

news:it5mku4fmcs44vok1sh18e0hemcn5tff52@4ax.com...
Quote
> I have a TGroupBox on my form with a number of controls
> on it.  If I set Enabled to false on the GroupBox, the controls
> are indeed not longer usable, but they don't grey out.
> So I go around disabling all the controls, and the now
> grey out.  However the caption on the GroupBox still
> won't grey.

> Any ideas?

Re:Disabled GroupBox


In article <it5mku4fmcs44vok1sh18e0hemcn5tf...@4ax.com>, Don Payette
wrote:

Quote
> I have a TGroupBox on my form with a number of controls
> on it.  If I set Enabled to false on the GroupBox, the controls
> are indeed not longer usable, but they don't grey out.
> So I go around disabling all the controls, and the now
> grey out.  However the caption on the GroupBox still
> won't grey.

Use this one instead:

unit PBGroupBox;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs,
  StdCtrls;

type
  TPBGroupBox = class(TGroupBox)
  private
    FOnHotkey: TNotifyEvent;
    { Private declarations }

    Procedure CMDialogChar( Var msg: TCMDialogChar );
      message CM_DIALOGCHAR;
    Procedure CMEnabledChanged( Var msg: TMessage );
      message CM_ENABLEDCHANGED;
  protected
    { Protected declarations }
    Procedure DoHotkey; dynamic;
  public
    { Public declarations }
  published
    { Published declarations }
    property OnHotkey: TNotifyEvent read FOnHotkey write FOnHotkey;
  end;

procedure Register;

Implementation

Uses ActnList;

procedure Register;
begin
  RegisterComponents('PBGoodies', [TPBGroupBox]);
end;

{ TPBGroupBox }

procedure TPBGroupBox.CMDialogChar(var msg: TCMDialogChar);
begin
  inherited;
  If msg.result <> 0 Then
    DoHotkey;
end;

procedure TPBGroupBox.CMEnabledChanged(var msg: TMessage);
var
  i: Integer;
begin
  for i:= 0 to controlcount-1 do
    If Enabled Then Begin
      If Assigned( Controls[i].Action ) Then
        Controls[i].Enabled := TAction(Controls[i].Action).Enabled
      Else
        Controls[i].Enabled := True
    End
    Else
      Controls[i].Enabled := False;
  If Enabled Then
    Font.Color := clBtnText
  Else
    Font.Color := clGrayText;
end;

procedure TPBGroupBox.DoHotkey;
begin
  If Assigned( FOnHotkey ) Then FOnHotkey( self );
end;

end.

--
Peter Below (TeamB)  
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be

Other Threads