how do i put a message box in a component?

Posted on 1998-02-03
Last Modified: 2010-04-04
i am writing a component which pops up a message box
which asks the user whether he wants to close a form
when he presses on the component..the component is
derived from tbutton
how do i make the message box pop up?
Question by:superboy
  • 3

Accepted Solution

StevenB earned 0 total points
ID: 1358225
 Use the MessageDlg or ShowMessage functions.


Expert Comment

ID: 1358226
how to use messagegdlg?

Expert Comment

ID: 1358227
 I really don't think that I can explain it any better than the delphi help:

MessageDlg displays a message dialog box in the center of the screen.


dialog and message routines

function MessageDlg(const Msg: string; AType: TMsgDlgType; AButtons: TMsgDlgButtons; HelpCtx: Longint): Word;

Call MessageDlg to bring up a message box and obtain the user's response. The message box displays the value of the Msg parameter.  Use the AType parameter to indicate the purpose of the dialog.  Use the AButtons parameter to indicate what buttons should appear in the message box.  Use the HelpCtx parameter to specify the context ID for the help topic that should appear when the user clicks the help button or presses F1 while the dialog is displayed.
MessageDlg returns the value of the button the user selected. These are the possible return values:

Return values            
mrNone          mrAbort         mrYes
mrOK            mrRetry         mrNo
mrCancel        mrIgnore        mrAll

TMsgDlgType defines values describing the type of message box.

  type TMsgDlgType = (mtWarning, mtError, mtInformation, mtConfirmation, mtCustom);

The TMsgDlgType type defines the values describing the type of message box. The TMsgDlgType is used by the MessageDlg and MessageDlgPos functions. The following table lists the possible values:

mtWarning       A message box containing a yellow exclamation point symbol.
mtError         A message box containing a red stop sign.
mtInformation   A message box containing a blue "i".
mtConfirmation  A message box containing a green question mark.
mtCustom        A message box containing no bitmap. The caption of the message box is the name of the application's executable file.

TMsgDlgButtons defines a set of values used by MessageDlg and MessageDlgPos.


  TMsgDlgBtn = (mbYes, mbNo, mbOK, mbCancel, mbAbort, mbRetry, mbIgnore, mbAll, mbHelp);

  TMsgDlgButtons = set of TMsgDlgBtn;

The TMsgDlgButtons type defines the set of values a button in a message box can have. The TMsgDlgButtons type is used by the MessageDlg and MessageDlgPos functions. The following tables lists the possible values:

Value      Meaning
mbYes            A button with a green check mark and the text 'Yes' on its face
mbNo            A button with a red circle and slash mark through the circle and the text 'No' on its face
mbOK            A button with a green check mark and the text 'OK' on its face
mbCancel      A button with a red X and the text 'Cancel' on its face
mbHelp        A button with a cyan question mark and the text 'Help' on its face
mbAbort       A button with a red check mark and the text 'Abort' on its face
mbRetry       A button with two green circular arrows and the text 'Retry' on its face
mbIgnore      A button with a green man walking away and the text 'Ignore' on its face
mbAll         A button with a green double check marks and the text 'All' on its face


Expert Comment

ID: 1358228
"Regarding superboy's question in the Experts Exchange(sm) Delphi Programming topic area titled "how do i put a message box in a component?"...

Congratulations!  You earned 0 quality points for answering superboy's question! These points will be added to your expert score in the Delphi Programming topic area."

Cheers Superboy. Its good to feel appreciated.


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JSON on ISAPI REST Server using Delphi 2 229
URL for downloading Google Chrome for Win XP 2 120
Firemonkey android show image from resource ? 1 32
update joined tables 2 30
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now