1

The problem is that when I try to set the TBitBtn.Enabled to False (when it is focused, like in the onClick event, and with VCL Styles enabled), it does not change the visual state, looking like it is stil enabled.

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

In the image, I just clicked in the bitbtn1

Rodrigo Caetano
  • 379
  • 1
  • 13
  • 2
    Workaround call `ActiveControl := nil;` before `BitBtn1.Enabled := False;` – RepeatUntil Dec 07 '16 at 16:43
  • cannot reproduce on Delphi DX10 (Seattle) without update 1 (version 23.0.20618.2753). Windows 8.1 SP1. – Zam Dec 07 '16 at 16:51
  • @RepeatUntil It works, thanks, but if possible I'd like to know if there is a more generic workaround, the source code is pretty huge. – Rodrigo Caetano Dec 07 '16 at 16:51
  • 1
    @Zam I'm with Seattle with Update 1, Windows 10. I just tried in Berlin Update 2 and I coud not reproduce either, so maybe it is a bug in the Seattle Update 1 – Rodrigo Caetano Dec 07 '16 at 16:59
  • If I disable the StyleElements.seClient it works too, but that is not an option for me, because in forms that I have Buttons and BitBtns together, the backgrounds would be different – Rodrigo Caetano Dec 07 '16 at 17:02

1 Answers1

0

I'm using a inherited component from TBitBtn in my project, so I override the setEnabled setter and used the workaround posted by @RepeatUntil:

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

  inherited;
end;

This solved my problem, but this looks like a bug from Seattle Update 1, because in Berlin Update 2 and Seattle without Update 1 (according to @Zam) the problem does not happen.

Rodrigo Caetano
  • 379
  • 1
  • 13