Detailed usage of MessageBox () in C ++

Source: Internet
Author: User

1. MessageBox ("this is the simplest message box! ");

 

2. MessageBox ("this is a message box with a title! "," Title ");

 

3. MessageBox ("this is a confirmation message box! "," Title ", mb_okcancel );

 

4. MessageBox ("this is a warning message box! "," Title ", mb_iconexclamation );

 

5. MessageBox ("this is a message box with two attributes! "," Title ", mb_iconexclamation | mb_okcancel );

6. If (MessageBox ("a common application", "title", mb_iconexclamation | mb_okcancel) = idcancel)
Return;

Additional 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 message box is used in the subclass of cwnd. 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 directly used.
The attributes listed here are only common attributes, and more attributes are available in msdn.

Error c2664: "cwnd: messageboxw" for compatibility with Visual C ++ 2005: parameter 1 cannot be converted from "const char [3]" to "lpctstr" Error 2 error c2664: "inet_addr": you cannot convert parameter 1 from "_ tchar *" to "const char *" D: \ Vc program \ clienttcp. CPP 29 cause: 2005 the default "use Unicode Character Set" solves: in the properties of the project file of the solution you created, select "use multi-Byte Character Set" for "Character Set Configuration property. 2005 this error does not occur when you open a 6.0 file because the compiling environment is converted during the conversion process.

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.