Error in Delphi 12 while using TTabControl (and how to rectify it)
As a Delphi beta tester, I was eager to have the new version of Delphi 12 installed for the development as soon as it is released in its official version. Nice to know that there are some pleasurable new features simplifying the migration from Delphi 11.3 in my case to Delphi 12. I'd mention a very easy and automated installation of Android SDK instead of using a command-line utilities in D 11.3, new permissions for Android 13 (READ_MEDIA_IMAGES for instance) or more reliable and stable working in design-time.
However, I encountered one very unpleasant and bothersome issue that degraded some of my apps and practically made using some of them impossible. The crucial symptoms were quite weird - missing texts or values in TEdit components (however they should have been visible normally) or invisible Map components at particular tabs within a TabControl component.
To be frank, the disclosure of the reason was not easy, I spent a couple of days and finally I've got an idea that Transition effect while calling SetActiveTabWithTransition could be the culprit. There was a simple line of code for switching among tabs and set the desired tab active and I did not have any suspicion before:
TabControl1.SetActiveTabWithTransition(TabItem2,TTabTransition.Slide);
Luckily, using another TTabControl method was a key for resolving the problem - the following code worked well for my purposes and the issues with the hidden texts and components dissappeared:
TabControl1.ActiveTab:=TabItem2;
Well, I do not have a transition effect while switching among tabs but the app works like a charm again.
Because the first occurence of this issue was intertwined with the TMSFNCMap component, I consulted the problem with TMS technical support at first - whether they made some modifications leading to the issue. Finally, we found out that the issue was general, and we've already reported it to the Quality Central. We hope this workaround will be useful for many developers until the update patch is released.
EDIT:
The issue was consulted also with Mr. Houf from CodeSecure (Embarcadero's commercial representation for Czech and Slovak republic) who found the reason could be in using sync version of SetActiveTab method. As is mentioned in Delphi Help, "SetActiveTabWithTransitionAsync is required when working on Android" - so after replacing SetActiveTabWithTransition by SetActiveTabWithTransitionAsync the app works correctly:
TabControl1.SetActiveTabWithTransitionAsync(TabItem2, TTabTransition.Slide, TTabTransitionDirection.Normal, nil);
But one question still persists: Why SYNC version of SetActiveTab worked well in Delphi 11.3 an on the same device and does not work in Delphi 12. Maybe some modifications in Android implementation can be the explanation.
About the Author
Ing. Karel Janecek, MBA, MSc.www.torry.net