FireMonkey Edits with different Colour when ReadOnly

Since the days when we developed our own GUI that ran on VGA 640×480 (developed in Turbo Pascal and heavily reliant on BASM), we have liked to show our Edits in different background colours depending on whether they are Read Only or nor.

So naturally when we got into Delphi our Edits had the ability to have a different background colour for Read Only (and other things) – and as ESBPCS evolved we added UICtrls that allowed a centralised way of assigning things such as Edit Read Only Colour. Of course this is optional 🙂

For the VCL side of our new ESBDevLib, we are continuing this approach whilst allowing our Edits to use the Styles that are now supplied in Delphi. (Note: ESBPCS does low level adjusting of controls to give various effects and these are not compatible with the new Styles – ESBDevLib doesn’t take this approach and thus is quite happy with the new Styles). So for the VCL side of things we believe we have the best of both worlds – you can use UICtrls to control things such as Read Only Colour, etc – or you can use the new Styles – or you can even use a combination of both.

Then we come to FireMonkey. I must admit I was a little “scared”. Back in the Kylix days, we spent a lot of time and money to start to port our components to CLX. We kept being told how easy it would be – but it was a nightmare – many of the low level features we needed didn’t get added to Kylix 3 – and Google wasn’t as useful back then. So whilst our Engines and Classes are working well in FMX, we also want our Edits to be there. As you probably are aware, the FMX Edits are similar to VCL Edits whilst being a totally different animal. For example, there is no Color Property – since the visual appearance is controlled by Styles. So whilst I am happy to use the FMX Styles – I would like my Edits to be a different colour when Read Only.

Our Solution (currently)

Please note we are not claiming any expertise in this area, rather are learning and playing with what we can do – and trying to make our ESBDevLib FMX Controls as flexible as possible. We are always open to suggestions of better approaches!

We added an OnReadOnlyChange Event to our Edits – so that this could be used to change the StyleLookup Properties between two different Edit Styles in the form’s StyleBook.

So here is a demo with 2 ESBDevLib Edits and a standard FMX Edit:



The two ESBDevLib Edits have the following Code Attached:




And when the Button is pressed and toggles all 3 controls ReadOnly State we get:


And we have set up two different Styles that only differ in their Background / Fill / Color:



So for this “need” the above works – and whilst it is not as “trivial” as our UICtrls in the VCL version – the addition of an Event allows us to easily implement this approach.

And for consistency we added the OnReadOnlyChange Event to the VCL Controls as well 🙂

BTW So far my experience with delving into FireMonkey is very positive compared to CLX  – so I hope Embarcadero continues to improve this Framework!


About esbglenn

Software Developer working at our Family owned business, ESB Consultancy, which is located in Kalgoorlie-Boulder, in the Eastern Goldfields of Western Australia.
This entry was posted in Beta Development, FireMonkey and tagged , , , . Bookmark the permalink.

3 Responses to FireMonkey Edits with different Colour when ReadOnly

  1. Mike Sutton says:

    Glenn, you can do all this with an animation in a single style and without needing the event handler with the code from my article at

  2. esbglenn says:

    We are doing much more playing with FMX Styles – thanks Mike – and not only is Mike’s blog one you should follow but also grab his MonkeyStyler – very useful.

    Ray Konopka’s Creating FireMonkey Components in XE3 is also worth watching – – I think we have a better handle on things 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.