【问题标题】:When focused, if set TBitBtn.Enabled to False it does not update it's visual state (with VCL Style on)聚焦时,如果将 TBitBtn.Enabled 设置为 False,它不会更新其视觉状态(打开 VCL 样式)
【发布时间】:2016-12-07 16:28:16
【问题描述】:

问题是当我尝试将 TBitBtn.Enabled 设置为 False 时(当它被聚焦时,例如在 onClick 事件中,并且启用了 VCL 样式),它不会改变视觉状态,看起来还是启用。

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
   BitBtn1.Enabled := False;
end;

在图片中,我只是点击了bitbtn1

【问题讨论】:

  • BitBtn1.Enabled := False;之前调用ActiveControl := nil;的解决方法
  • 无法在没有更新 1(版本 23.0.20618.2753)的 Delphi DX10(西雅图)上重现。 Windows 8.1 SP1。
  • @RepeatUntil 它可以工作,谢谢,但如果可能的话,我想知道是否有更通用的解决方法,源代码非常庞大。
  • @Zam 我在西雅图使用更新 1,Windows 10。我刚刚在柏林更新 2 中尝试过,但我也无法重现,所以这可能是西雅图更新 1 中的错误
  • 如果我禁用 StyleElements.seClient 它也可以工作,但这对我来说不是一个选项,因为在我同时拥有 Button 和 BitBtns 的表单中,背景会有所不同

标签: delphi delphi-10-seattle vcl-styles


【解决方案1】:

我在我的项目中使用了从 TBitBtn 继承的组件,因此我覆盖了 setEnabled 设置器并使用了@RepeatUntil 发布的解决方法:

procedure TCustomBitBtn.SetEnabled(Value: Boolean);
begin
  if Focused then
    Winapi.Windows.SetFocus(0);

  inherited;
end;

这解决了我的问题,但这看起来像是西雅图更新 1 中的一个错误,因为在柏林更新 2 和没有更新 1 的西雅图(根据@Zam),问题不会发生。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-12
    • 2021-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多