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 ()