Monday, September 30, 2013

Rambling: The FMX Control Repaint Menace

Well I have been developing data management apps for businesses and the government in FMX and yes, the apps need more time to mature vs VCL. But I have come to understand that the customization power of FMX is unmatched and providing my clientele their wished features, useful and ridiculous alike, is easier in it instead.

Now to the topic, the most frustrating issue in the FMX framework is the repainting / updating / invalidating etc of a control and honestly the only one which hinders me. I have dealt with or worked around all others. I never use Application.ProcessMessages, it is a horror, best left alone. I normally end up using in combination all the available methods or if nothing comes to fruition, exposing the hidden ones through hack classes, or rewriting the controls if all results in vain.

I haven't tried or explored any WinAPI based solutions, I am kinda afraid of them, the methods and their arguments make me dizzy (who the hell designed them, what were they thinking! And I just get lost in it...).

I remember last month I was developing my largest DMS spanning multiple labs and their controlling govt authority, and when I was ready to give it its first release status, I included an additional progress bar for smaller transactions with the remote databases. The first run, and a bomb exploded in my head, nothing was showing up, no grids, buttons, nothing on the parent layout of the progress bar. I reverted back through the SVN but the same result. Anyways after 4 days and a question on stackoverflow to no gain, I randomly started putting in methods that may even be remotely connected, and I found an unreliable solution, but a solution which was SetFocus! -_- After fiddling with may combinations that I was able to get all the controls displayed correctly. Like handling the grids first, then the progress bar and lastly the buttons.


Well here is a recent post about this issue at Delphi-Haven which is much better if one wants to get an in depth understanding of the matter. Also it has a solution for updating the controls by updating the whole form using WinAPI:
FMX Issue: Inability to safely process paint messages immediately

That solution works for me for less congested forms but doesn't for otherwise as I usually work with layers and a single main form to accommodate all interface jobs.

No comments:

Post a Comment