C + + MessageBox ()

Source: Internet
Author: User
Tags windows 7 x64

For the MessageBox function, refer to: https://msdn.microsoft.com/en-us/library/ms645505 (vs.85). aspx

For more examples, refer to Using Dialog Boxes(https://msdn.microsoft.com/en-us/library/ms644996 (v=vs.85). Aspx#message_box)

Ide:code::blocks 16.01

Operating system: Windows 7 x64

1#include <windows.h>2#include <tchar.h>3 4 /*in the following example, the application displays a message box5 That prompts, the user for a action after a error condition has occurred.6 The message box displays the message that describes the error condition7 And how to resolve it.8 The mb_yesno style directs MessageBox to provide-buttons9 With which the user can choose what to proceed:*/Ten intDisplayconfirmsaveasmessagebox () One { A     intMsgboxid =MessageBox ( - NULL, -         "Temp.txt already exists.\ndo you want to replace it?", the         "Confirm Save as", -mb_iconexclamation |Mb_yesno -     ); -  +     if(Msgboxid = =idyes) -     { +         //Todo:add Code A     } at  -     returnMsgboxid; - } -  - int_cdecl _tmain () - { in Displayconfirmsaveasmessagebox (); -  to     return 0; +}

Running results in Code::Blocks 16.01:

Ide:microsoft Visual Studio Community 2017 15.5.2

Operating system: Windows 7 x64

1#include"stdafx.h"2 3#include <windows.h>4 5 /*in the following example, the application displays a message box6 That prompts, the user for a action after a error condition has occurred.7 The message box displays the message that describes the error condition8 And how to resolve it.9 The mb_yesno style directs MessageBox to provide-buttonsTen With which the user can choose what to proceed:*/ One intDisplayconfirmsaveasmessagebox () A { -     intMsgboxid =MessageBox ( - NULL, theL"Temp.txt already exists.\ndo you want to replace it?", -L"Confirm Save as", -mb_iconexclamation |Mb_yesno -     ); +  -     if(Msgboxid = =idyes) +     { A         //Todo:add Code at     } -  -     returnMsgboxid; - } -  - int_cdecl _tmain () in { - Displayconfirmsaveasmessagebox (); to  +     return 0; -}

Running results in Microsoft Visual Studio Community 2017 15.5.2:

Parameters about the MessageBox () :

The first one, not very understanding.

Second, specify the text information to display.

Third, specify a caption for the message box.

Fourth, specify icons, keys, and so on.

C + + MessageBox ()

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.