0
Fala galera,
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:
Buttoncancelar.Enabled:=true
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 found that only happens when the button starts with enable or Visible false. Now the resolution still have no idea
EDIT 3
procedure TControl.EnabledChanging;
begin
DoCallNotifyHandler(chtOnEnabledChanging);
end;
procedure TControl.DoCallNotifyHandler(HandlerType: TControlHandlerType);
begin
FControlHandlers[HandlerType].CallNotifyEvents(Self);
end;
EDIT 4
Doing some tests, if I duplicate the button and run one or the other, the form only disables the button that trigger the event, so if I have put-IT and the boot-B and tighten the put-IT only it will be disabled, even if the function disables both.
It takes this line, executes the event I called (in case the Operation click) and even proceeds but practically it calls 2 events
– Vinicius.Beloni
Code the two functions(
EnabledChanging
andEnabledChanged
) also, I looked here in classTControl
in thedelphi 7
and there are no such two calls.– Roberto de Campos
So, I didn’t put any event on these guys, I’ll edit and put the codes
– Vinicius.Beloni
And the
EnabledChanged
?– Roberto de Campos
falls in the same...
– Vinicius.Beloni