I've got a TBitBtn on a TFrame with a click event that causes the button's own frame to get unparented from its container (effectively removing it) and stored for later restoration:
implementation
var
StoredFrames: TStack<TFrame>;
procedure TCustomFrame.BitBtnClick(Sender: TObject);
begin
// Some business logic
Self.ActiveControl := nil;
Self.Parent := nil;
StoredFrames.Push(Self);
end;
Later, the frame is reparented into its container and thus redisplayed. However, the blue highlighting the button got from the mouse when it was clicked, before getting stored, remains on the button:
After restoration, other controls can receive the same highlighting at the same time, but the button does not lose its highlighting until the frame is destroyed. How can I manually reset or remove this button highlighting?
Things I've tried:
Application.ProcessMessagesin the click handler- Disabling the button on store, enabling on restore
- Various kinds of repainting/layout invalidation
