messagebox (handle, ‘do you really want to exit?’, ‘are you sure?’, 1);
in this button there are two things, what the user can do. ok and cancel. what code do i have to write, that the button closes the program at ‘ok’ and ends the dialog, when pressing cancel?
Delphi provides better solutions for showing a messagebox. I should use the MessageDlg function. The return value of the MessageDlg (and MessageBox) function indicates the users choice. So you when you place a yes button on the MessageDlg, the return value will be mrYes when the user presses the Yes button. So your code would be like this:
You also want to close your application if the users chooses Yes. When you have a normal Delphi VCL application you can implement the CloseQuery event of you mainform, the CloseQuery event is executed when you try to close your mainform (like clicking the closebutton) and has a variable CanClose. Setting CanClose to True means the MainForm is OK to close, setting it to false will prevent your mainform from closing: