Instead of using Enabled use ReadOnly, Color and Font.Color.

This also allows the user to select the text from the edit, or combo but
they can't change it.

If you don't want to go "if Blah is TWhatever then begin" for all components
that support ReadOnly take a look at SetOrdinalProperty with uses RTTI to
decide if a component has the ReadOnly property.

eg. SetOrdinalProperty(PComponent, 'ReadOnly', System.TypeInfo(Boolean),
Integer(False));

I believe that this is fairly slow though and shouldn't be used in tight
loops.

Stacey

> -----Original Message-----
> From: David Brennan 
> Sent: Wednesday, 22 November 2000 2:44 p.m.
> To: Multiple recipients of list delphi
> Subject: [DUG]: Appearance of disabled controls
> 
> 
> I would like to change the behaviour of my inherited controls 
> (such as edit
> boxes, combos, memos etc) so that when they are disabled the 
> background is
> gray, but the text remains black.
> 
> Setting the background to gray is easy - for example code like...
> 
> procedure TDbbDBEdit.CMEnabledChanged(var Message: TMessage); Message
> CM_ENABLEDCHANGED;
> begin
>   inherited;
>   if Enabled then begin
>     Color := clWindow;
>   end
>   else begin
>     Color := clBtnFace;
>   end;
> end;
> 
> ... or similar will do it. However the edit box insists on 
> drawing the text
> in dark gray, regardless of the Font Colour setting. Delphi 
> doesn't seem to
> have any code for this so it must be default behaviour by windows for
> drawing disabled edit controls. Combo boxes etc have the same 
> problem, which
> I would also like to get around.
> 
> Is there any way around this behaviour. For example can it be 
> changed by
> changing the parameters/style in CreateParams? If so what is the
> code/constants etc. Any other suggestions welcome.
> 
> Thanks,
> David.
> 
> 
> --------------------------------------------------------------
> -------------
>     New Zealand Delphi Users group - Delphi List - 
> [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED] 
> with body of "unsubscribe delphi"
> 
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to