I'm trying to do what my question says, when the user clicks the close button on the form, I want to prompt the user to confirm it, this is the code I came up with... It is problematic, when I click on the close button, it does prompt me to confirm, but the program closes anyway, irrelevant of the button I click, what am I doing wrong?
procedure TfrmLogin.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if MessageDlg('Are you sure you want to exit?', mtWarning, [tMsgDlgBtn.mbYes, tMsgDlgBtn.mbCancel], 0) = 0 then
begin
Application.Terminate;
end;
end;