Differences between afxmessagebox () and MessageBox ()

Source: Internet
Author: User

From http://leadtheway.iteye.com/blog/825177

Afxmessagebox function prototype
Int afxmessagebox (lpctstr lpsztext, uint ntype = mb_ OK, uint nidhelp = 0 );
Int afxapi afxmessagebox (uint nidprompt, uint ntype = mb_ OK, uint nidhelp = (uint)-1 );
In the first form, lpsztext indicates the text displayed inside the message box. The title of the message box is the executable file name (such as Hello) of the application ). In the second form, nidprompt is the ID of the text string to be displayed in the string table. When the function is called, the string is automatically loaded from the string table and displayed in the message box. Ntype is a combination of the button style and Icon style displayed in the message box. You can use the | (OR) operator to combine various styles.

Button Style
The "Abort", "retry", and "Ignore" buttons are displayed in the mb_abortretryignore message box.
Mb_ OK show OK button
Mb_okcancel: Show OK and cancel buttons
Mb_retrycancel: Display retry and cancel buttons
Mb_yesno: Yes and no buttons are displayed.
The mb_yesnocancel button indicates yes, no, and cancel.
Icon Style
Mb_iconinformation displays an I icon, indicating a prompt
Mb_iconexclamation displays an exclamation point, indicating a warning.
Mb_iconstop: displays the hand icon, indicating a warning or serious error.
Mb_iconquestion: displays the question mark icon, indicating a question

MessageBox, a function similar to afxmessagebox, Is a member function of the cwnd class:
Int MessageBox (maid, maid = NULL, uint ntype = mb_ OK );

The difference between the two functions: afxmessagebox is simpler than MessageBox, because it is a global function, so it does not need a corresponding window class, but cannot control the message box title, it is often used for internal data output or warning during program debugging; MessageBox is more formal, often used in the application version to be submitted, you can control the title content without using an executable file name with unknown meanings as the title.

Example:
Afxmessagebox ("Are you sure ?", Mb_yesno | mb_iconquestion );
Int A = MessageBox (text ("are you sure you want to delete it? "), Text (" Warning !! "), 4 );
If (A = 6)
Afxmessagebox ("yes ");
Else
Afxmessagebox ("no ");
(Where # define idyes 6 # define IDNO 7)

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.