Mudar cor de um DBEdit quando for Enabled := False

Delphi

11/03/2005

Olá pessoal, estou com essa dúvida..

Tenho no meu sistema vários forms de cadastros e tals... com DBEdit, porem, queria fazer o seguinte: quando abrisse o form, verificasse quais compoentne DBEdit fosse Desabilitado e mudasse a cor dele para clBtnFace e a Fonte para clBlack, caso contrário ficaria clWindow e fonte clBlack..

Porem fazer isso na mao em meus Forms, fica impossivel..

queria algo que fizesse um fez e valesse para todos os forms...

alguem tem alguma dica?


desde ja agradeco


[]s


Titanius

Titanius

Curtidas 0

Respostas

Macario

Macario

11/03/2005

DesabilitaComp(Self);

Function DesabilitaComp(Wform : Tform): Boolean;
Var
  WCount : Integer;
Begin
  For WCount := 0 to Wform.ComponentCount - 1 do
  Begin
    if (Wform.Components[WCount] is TDBEdit) Then
       TDBEdit(Wform.Components[WCount]).Enabled          := False
    else if ( Wform.Components[WCount] is TDBComboBox) then
      TDBComboBox(Wform.Components[WCount]).Enabled := False
    else if ( Wform.Components[WCount] is TEdit) then
      TEdit(Wform.Components[WCount]).Enabled := False
    else if (Wform.Components[WCount] is TMAskEdit) then
      TMaskEdit(Wform.Components[WCount]).Enabled         := False
    else if (WForm.Components[WCount] is TCheckBox) then
      TCheckBox(Wform.Components[WCount]).Enabled         := False
    else if (Wform.Components[WCount] is TDBLookupComboBox) then
      TDBLookupComboBox(Wform.Components[WCount]).Enabled := False
    else if (WForm.Components[WCount] is TDBCheckBox) then
      TDBCheckBox(Wform.Components[WCount]).Enabled       := False
    else if (Wform.Components[WCount] is TComboBox) then
      TComboBox(Wform.Components[WCount]).Enabled         := False
    else if (Wform.Components[WCount] is TDBRadioGroup) then
      TDBRadioGroup(Wform.Components[WCount]).Enabled     := False
    else if (Wform.Components[WCount] is TDbMemo) then
      TDbMemo(Wform.Components[WCount]).Enabled           := False
    else if (Wform.Components[WCount] is TMemo) then
      TMemo(Wform.Components[WCount]).Enabled             := False
    else if (Wform.Components[WCount] is TGroupBox) then
      TGroupBox(Wform.Components[WCount]).Enabled         := False
    else if (Wform.Components[WCount] is TRadioGroup ) then
      TRadioGroup(Wform.Components[WCount]).Enabled       := False
    else if (Wform.Components[WCount] is TCurrencyEdit ) then
      TCurrencyEdit(Wform.Components[WCount]).Enabled     := False
    else if (Wform.Components[WCount] is TdxButton ) then
      TdxButton(Wform.Components[WCount]).Enabled     := False
    else if (Wform.Components[WCount] is TFlatGroupBox ) then
      TFlatGroupBox(Wform.Components[WCount]).Enabled     := False
    else if (Wform.Components[WCount] is TFlatCheckBox ) then
      TFlatCheckBox(Wform.Components[WCount]).Enabled     := False
    else if (Wform.Components[WCount] is TFlatEdit ) then
      TFlatEdit(Wform.Components[WCount]).Enabled     := False
    else if (Wform.Components[WCount] is TFlatSpinEditInteger ) then
      TFlatSpinEditInteger(Wform.Components[WCount]).Enabled     := False;

  End;
  DesabilitaComp := True;
end;


Tenta isso, ve se serve. :roll:


GOSTEI 0
Bruno Belchior

Bruno Belchior

11/03/2005

coloca no OnShow:
proceure MudaEstado(ProximoEstado: Boolean);
var Cont: Integer;
begin
  for Cont := 0 to Form.ComponentCount - 1 do 
   if (Form.Components[Cont] is TWinControl) then 
     (Form.Components[Cont] as TWinControl).Enabled := ProximoEstado; 
  Form.Refresh;
end;



GOSTEI 0
Fred

Fred

11/03/2005

eh a cor que o cara quer mudar!!!
coloca ae no onshow do form pode ser!!

var Cont: Integer;
begin
for Cont := 0 to Form.ComponentCount - 1 do
if (Form.Components[Cont] is TDBEditl) then
if not DBEdit.enable then // ou use sem o not
begin
(Form.Components[Cont] as TDBEdit).color := clcorescolhida;
(Form.Components[Cont] as TDBEdit).font.color := clcorescolhida2;
end;
end;


GOSTEI 0
Titanius

Titanius

11/03/2005

Valeu pela ajuda galera! :D:D:D


[]s


GOSTEI 0
POSTAR