delphibuttonevent-handlingvcl

How can I simulate the press of a button?


I want to test some forms. Is there a way to simulate the press of an Ok (or Cancel) button so that the button is pressed and fires the event handlers that are associated with it?


Solution

  • The cleanest approach is to call the Click method of the button. This is better than the alternatives for these reasons: