TAdvEdit - OnExit called when entering

I have a TAdvEdit component that has an OnExit event handler that is being called when I enter the component (after OnEnter) and OnEnter is being called twice, which is a problem as I am using these events as counters. I traced this to a call in TCustomAdvEdit.SetEditAlign to ReCreateWnd which seems to be only called if FocusAlign is not set to the default (Left) value. I have got around the problem on my app by temporarily nilling OnEnter and OnExit in SetEditAlign - see Change alignment without RecreateWnd? - delphi. Not sure if there is a more elegant way to achieve the same thing?

I could not reproduce this based on this information.

Test with default TAdvEdit:

procedure TForm1.AdvEdit1Enter(Sender: TObject);
begin
  outputdebugstring('on enter');
end;

procedure TForm1.AdvEdit1Exit(Sender: TObject);
begin
  outputdebugstring('on exit');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  AdvEdit1.EditAlign := eaCenter;
  AdvEdit1.FocusAlign := eaRight;
end;

I thought I was going mad for a while and couldn't reproduce it eitther. Finally found the source of the different behaviour. In my app the Edit control is on a Frame on a form rather than directly on the form. It seems to be the Frame that is provoking the issue. Not sure if this is a TFrame issue or a TAdvEdit problem?

It is indeed a frame related issue.
We implemented a workaround for this scenario.