MessageBox Windows
///////////////////////////////////////////////////////////////////
//////////////////// CODE WRITTEN BY PROGRAMEXE ///////////////////
///////////////////////////////////////////////////////////////////
#include <windows.h> // Allows you to use the MessageBox command along with all of its parameters and flags, click here to learn about windows.h: https://docs.microsoft.com/en-us/windows/win32/api/winbase/
#include <iostream> // Allows you to input and output into console such as: cout and cin.
using namespace std; // So you dont have to type std:: everytime you write a string
int main()
{
// Message box parameters are, MessageBox(HWND, Message, Messagebox Title, UINT)
// You can find all of the UINT flags here: https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebox */
// ---------------------------------------------- MessageBox Example 1: ----------------------------------------------
MessageBox(FindWindowA("ConsoleWindowClass", NULL), "Hello there!", "MessageTitle", MB_OK | MB_ICONINFORMATION);
// This example will display a Messagebox with the title, "MessageTitle", and containing the message, "Hello there".
// The MB_OK flag gives the MessageBox an OK button which returns an int value.
// The MB_ICONINFORMATION gives the message box the windows information icon on the left while playing the windows information sound.
// ---------------------------------------------- MessageBox Example 1: ----------------------------------------------
if (MessageBox(FindWindowA("ConsoleWindowClass", NULL), "Hello, please press OK.", "MessageTitleOK", MB_OKCANCEL | MB_ICONINFORMATION) == IDOK) // MB_OKCANCEL give the MessageBox an OK button and a Cancel button. If it was MB_OK, both the X and the OK will return IDOK and this if statement would fail.
{
cout << "OK!";
}
else
{
cout << "NOT OK :(";
}
// This example displays a MessageBox with an if statement looking to see if you pressed OK.
// If you pressed OK, it outputs "OK" into console.
// If you press the X or Cancel, the code outputs "NOT OK :(" into the console.
}
ProgramEXE