VCL controls are supported by Win32 controls, and they are inherently unsafe. You cannot restrict access to their properties and state. External programs can easily change state, press buttons, etc.
You may be tempted to start a timer that resets the user interface at high frequency. This can make it a little harder for a cracker. But still not particularly difficult, and at what price is your program and code?
So, in my opinion, you should not try to stop external programs that impede the state of the user interface. Instead, you can add checks and protections to OnClick handlers and other code behind the interface. This is also awesome, but at least it takes a little more effect from the cracker.
You can write:
button.Enabled := False; button.OnClick := nil;
when you turn off the button. When you turn it back on, you can write:
button.Enabled := True; button.OnClick := MyOnClickHandler;
This is a pretty crude way to do this. It might be preferable to click on call chain checking in the OnClick handler OnClick or, better yet, further into your business logic. Thus, no matter how the code reaches the business logic, if it needs to be locked, it will.
source share