Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 124233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T04:24:47+00:00 2026-05-11T04:24:47+00:00

messagebox (handle, ‘do you really want to exit?’, ‘are you sure?’, 1); in this

  • 0

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?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T04:24:47+00:00Added an answer on May 11, 2026 at 4:24 am

    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:

    var   ShouldClose: Boolean; begin   if MessageDlg('Do you really want to quit?', mtConfirmation,        [mbYes, mbNo], 0) = mrYes then     ShouldClose := True   else     ShouldClose := False; end; 

    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:

    procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin   CanClose := MessageDlg('Do you really want to quit?', mtConfirmation,      [mbYes, mbNo], 0) = mrYes; end; 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

MessageBox.Show((some_string.Length).ToString); I am getting two errors for this: The best overloaded method match for
I want to show messagebox to the user, such that the user cannot refuse
Im using System.Windows.MessageBox.Show() to display a dialog to the user. One overload lets me
I have been using win32api.MessageBox to do alerts, and this works for apps running
I have a button column on a DataGridView and I am trying to handle
In my projects (WPF) I use System.Windows.MessageBox to show the user a confirmation dialog
I want to do the following with my javascript codeblock. Handle all current and
I have a C# app where I'm using Messagebox.Show with a help button, as
I would really appreciate your help in this. I have been trying to get
I am trying to handle the 'Cancel' button in my property pages (wizard) and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.