Fórum Mudar cor de um DBEdit quando for Enabled := False #272045
11/03/2005
0
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
Curtir tópico
+ 0Posts
11/03/2005
Macario
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
11/03/2005
Bruno Belchior
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
12/03/2005
Fred
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
13/03/2005
Titanius
[]s
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)