Talk to people,
By changing the (TButton) button to disabled within an event, it triggers another event.
procedure TFormulario.OnButtonExecutarOperacaoClick(Sender: TObject);
begin
//...
//aqui está o problema
//a função abaixo é sincrona assim ele trava nesta linha porque chamou o evento denovo
ButtonCancelar.Enabled:=true;//.Visible também tem o mesmo comportamento
FuncaoQueNaoChamaPorCausaDesteProblema();
end;
Without this:
ButtonCancel.Enabled: = true
it works normally.
EDIT 1 : control.inc
procedure TControl.SetEnabled(Value: Boolean);
begin
if FEnabled <> Value
then begin
EnabledChanging; //aqui chama o evento do OnButtonExecutarOperacaoClick
FEnabled := Value;
Perform(CM_ENABLEDCHANGED, 0, 0);
EnabledChanged;
end;
end;
EDIT 2 I discovered that this only happens when the button starts with enable or visible false. Now the resolution still has no idea
EDIT 3
procedure TControl.EnabledChanging;
begin
DoCallNotifyHandler(chtOnEnabledChanging);
end;
procedure TControl.DoCallNotifyHandler(HandlerType: TControlHandlerType);
begin
FControlHandlers[HandlerType].CallNotifyEvents(Self);
end;
EDIT 4
button button B and pressing the A-button will only disable it, even if the function will disable both.