OnClick
Description
Occurs when the user clicks the component. The event also allows you to prevent the selected action for the button.
Examples
procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
begin
Cancel := True; // If the Cancel parameter is set to True, the action that is assigned to the button will not be executed
end;
procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
begin
if IDNO = MessageBox('Execute an action?', 'Caption', MB_YESNO+MB_ICONQUESTION) then // If the user clicked No
begin
Cancel := True; // If the Cancel parameter is set to True, the action that is assigned to the button will not be executed
end;
end;