Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ messagebox

///////////////////////////////////////////////////////////////////
//////////////////// 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.
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ read console input 
Cpp :: simple C++ game code 
Cpp :: rng c++ 
Cpp :: c++ get length of array 
Cpp :: sfml delta time 
Cpp :: how to cehck if list has element c++ 
Cpp :: for loop vector 
Cpp :: round all columns in R dataframe to 3 digits 
Cpp :: should i learn c or c++ 
Cpp :: c++ set console title 
Cpp :: ue4 get bone location c++ 
Cpp :: unreal get eobjecttypequery cpp´ 
Cpp :: what are specialized classes c++ 
Cpp :: watermelon codeforces solution 
Cpp :: declare dictionary cpp 
Cpp :: for loop reverse C++ 
Cpp :: initialzing a 2d vector in cpp 
Cpp :: call of overloaded ‘swap(int&, int&)’ is ambiguous 
Cpp :: print queue c++ 
Cpp :: c++ find key in hashmap 
Cpp :: recursive binary search 
Cpp :: C++ passing function arguments to a thread 
Cpp :: how to get double y dividing 2 integers in c++ 
Cpp :: fork c 
Cpp :: format string cpp 
Cpp :: what is the difference between i++ and ++ i ? 
Cpp :: include spaces while reading strings in cpp 
Cpp :: how to copy one vector to another 
Cpp :: chrono library c++ 
Cpp :: c++ printf char as hex 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =