您的位置:首页 > 编程语言 > Delphi

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

2017-03-22 15:25 225 查看
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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  delphi
相关文章推荐