delphi 禁用掉窗口中的所有组件

来源:互联网 发布:ip地址网络字节序 编辑:程序博客网 时间:2024/06/05 20:03
procedure DisableAllControls(m_form: TWinControl; m_enable : Boolean = false);var i : integer;begin  //禁用窗口中所有组件  //m_enabled = true 表示启用  for i := 0 to m_form.ComponentCount - 1 do  begin    if m_form.Components[i] is TCustomTreeView then      (m_form.Components[i] as TCustomTreeView).Enabled := m_enable;    if m_form.Components[i] is TCustomButton then      (m_form.Components[i] as TCustomButton).Enabled := m_enable;    if m_form.Components[i] is TCustomDBGridEh then      (m_form.Components[i] as TCustomDBGridEh).Enabled := m_enable;    if m_form.Components[i] is TToolBar then      (m_form.Components[i] as TToolBar).Enabled := m_enable;    if m_form.Components[i] is TGroupBox then      (m_form.Components[i] as TGroupBox).Enabled := m_enable;  end;  if m_form is TForm then  //最后禁用掉自己    (m_form as TForm).Enabled := m_enable;end;

0 0
原创粉丝点击