Como saber se existe um componente?

Delphi

02/08/2005

Olá eu uso esta função genérica:
if (Key = vk_F6) and (TBitBtn(FindComponent(´BtnExcluir´)).Enabled) then
    TBitBtn(FindComponent(´BtnExcluir´)).Click;


O problema, é que em determinadas telas eu não tenho o BtnExcluir, queria saber se tem como eu verificar se existe o botão e depois eu executar esta função acima.. assim não dá erro. ;D

[]s

Fellipe H.


Titanius

Titanius

Curtidas 0

Respostas

Rjun

Rjun

02/08/2005

Use o próprio FindComponent. Ele retorna nil se o componente não existir.


GOSTEI 0
Ivanh

Ivanh

02/08/2005

if (Key = vk_F6) and
  (FindComponent(´BtnExcluir´) <> nil) and
  (TBitBtn(FindComponent(´BtnExcluir´)).Enabled) then
    TBitBtn(FindComponent(´BtnExcluir´)).Click;



GOSTEI 0
Titanius

Titanius

02/08/2005

Valeu pessoal :lol: :lol:


GOSTEI 0
POSTAR