1
votes

In a Delphi 10.4 VCL Application, TCard (as container-item of TCardPanel) does not have public OnShow and OnHide events (like TTabSheet has).

Therefore, the TCard.OnEnter event-handler is NOT triggered when a specific TCard is ACTIVATED. The TCard.OnEnter event-handler is triggered ONLY when e.g. clicking on a control on the TCard.

Example code:

CardPanel1.ActiveCard := Card2;

In this case, the TCard.OnEnter event is NOT triggered!

Is it possible to upgrade the TCard class with public OnShow and OnHide events? Or is it possible to simulate those events?

1
Can't you just use the OnCardChange event of the TCardPanel? - Uwe Raabe
@UweRaabe I have tried to use the OnCardChange event of the TCardPanel: When I try to use PrevCard.Name or NextCard.Name as string in that event-handler to identify the card then I get a run-time error. Now, I could use NextCard.Caption to identify the card, but that leads to "Code-Smell", as the captions could change at runtime. The CLEANEST solution would be upgrading to a TCard.OnShow event. - user1580348
Why don't you use ActiveCard? - Olivier
@Olivier In which context? - user1580348
Why refer to the name? Just write if NextCart = Card1 or `if PrevCard = Card2' or whatever makes sense here. Hard to give advice without knowing the actual use case. - Uwe Raabe

1 Answers

2
votes

Use the OnCardChange event of TCardPanel and compare PrevCard and/or NextCard with your actual card instances.