MessageBox usage in Delphi

Source: Internet
Author: User

 

Message box is a common control with many attributes. This article lists some of its common methods and its application scenarios.

1. Simple usage, without graphics

MessageBox (0, 'disagree ', 'hs', MB_ OK );

MessageBox (0, 'disagree ', 'hs', MB_OKCANCEL );

2. warning dialog box:

MessageBox (0, 'password cannot be blank, please enter password', 'Warning ', MB_ICONEXCLAMATION );

3. Prompt dialog box:

MessageBox (0, 'password cannot be blank, please be sure to enter password', 'hs', MB_ICONASTERISK and MB_ICONINFORMATION );

4. complex usage:

MessageBox (Handle, PChar ('process' + Listview1.Selected. caption + 'cannot be ended! '), PChar ('hprompt'), MB_ICONEXCLAMATION );

Common attributes

Default System icon, which can be displayed in the message box
X error MB_ICONHAND, MB_ICONSTOP, and MB_ICONERROR
? Ask MB_ICONQUESTION
! Warning MB_ICONEXCLAMATION and MB_ICONWARNING
I Information MB_ICONASTERISK and MB_ICONINFORMATION

Button format
MB_ OK default
MB_OKCANCEL confirm cancel
MB_YESNO?
Whether MB_YESNOCANCEL is canceled

Return Value
Idcancel unselect
IDNO no selected
Idok determines to be selected
Idyes is selected

Supplement:
The above message box is used in Delphi. If not, MessageBox (null, "DDD", "DDD", mb_ OK); or MessageBox (hwnd, "DDD ", "DDD", mb_ OK); hwnd is the handle of a window, or afxmessagebox is used directly.

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.