Use of the MessageBox in Delphi (GO)

Source: Internet
Author: User

MessageBox dialog is a more commonly used Information dialog box, which can not only define the displayed information content, information hint icon, but also can define the button combination and dialog box title, is a full-featured Information dialog box information hint icon, and can define the button combination and dialog box title, is a full-featured information on the box.

1. function prototype and Parameters

function MessageBox (Hwnd:hwnd; Text, Caption:pchar; Type:word): Integer;

HWnd: Dialog Parent window handle, dialog box appears in the Delphi window, you can use the form's handle property, otherwise 0, make it directly as a child window of the desktop window.

Text: The string of information to display.

Caption: Dialog box title string.

Type: Constant for the dialog box.

The return value of the function is an integer that is used for the recognition of the dialog button.

2. Type Constants

The Type constants for dialog boxes can be combined by a combination of buttons, default buttons, display icons, and four constants of run mode.

(1) button combination constants

MB_OK = $00000000; A OK button

Mb_okcancel = $00000001; A OK button, a Cancel button

Mb_abortretryignore = $00000002; An abort button, a retry button, a ignore button

Mb_yesnocancel = $00000003; One is a button, a No button, a Cancel button

Mb_yesno = $00000004; One is a button, a No button

Mb_retrycancel = $00000005; A retry button, a Cancel button

(2) Default button constants

Mb_defbutton1 = $00000000; The first button is the default button

Mb_defbutton2 = $00000100; The second button is the default button

Mb_defbutton3 = $00000200; The third button is the default button

Mb_defbutton4 = $00000300; The fourth button is a default button

(3) Icon constants

Mb_iconhand = $00000010; "X" number icon

Mb_iconquestion = $00000020; “? "Number icon

Mb_iconexclamation = $00000030; “! "Number icon

Mb_iconasterisk = $00000040; "I" icon

Mb_usericon = $00000080; User icon

mb_iconwarning = mb_iconexclamation; “! "Number icon

Mb_iconerror = Mb_iconhand; "X" number icon

Mb_iconinformation = Mb_iconasterisk; "I" icon

Mb_iconstop = Mb_iconhand; "X" number icon

(4) Operating mode constants

Mb_applmodal = $00000000; Application mode, which can be switched to another application before the dialog box is closed

Mb_systemmodal = $00001000; System mode, you must close the dialog box before you can do other things

Mb_taskmodal = $00002000; Task mode, you can switch to another application before the dialog box is closed

Mb_help = $00004000; Help Button

3. function return value

0//dialog box failed to build

IdOk = 1/Press the OK button

IdCancel = 2/Press the Cancel button

Idabout = 3//Press the Abort button

Idretry = 4//Press Retry button

Idignore = 5/Press the Ignore button

Idyes = 6/Press Yes button

Idno = 7//Press no button

Example: MessageBox (0, ' No Play type selected ', ' Error ', mb_iconexclamation);

--application.messagebox (' MessageBox ', ' warning ', mb_iconwarning+mb_yesno);

--messagebox (Form1.handle, ' MessageBox ', ' hint ', mb_iconinformation+mb_okcancel);

--messagebox (Form1.handle, ' MessageBox ', ' hint ', mb_iconinformation+mb_okcancel+mb_defbutton2);

--If MessageBox (Form1.handle, ' MessageBox ', ' hint ', mb_iconinformation+mb_okcancel) = IdOk Then

Begin

ShowMessage (' Ok ');

End

Use of the MessageBox in Delphi (GO)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.