Search
 
SCRIPT & CODE EXAMPLE
 

CPP

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

PREVIOUS NEXT
Code Example
Cpp :: c++ chrono get milliseconds 
Cpp :: clear file before writing c++ 
Cpp :: unordered_map of pair and int 
Cpp :: c++ delete directory 
Cpp :: Runtime Error: Runtime ErrorBad memory access (SIGBUS) 
Cpp :: c++ vector pop first element 
Cpp :: c++ print hello world 
Cpp :: how to shut down windows in c++ 
Cpp :: compile multiple files C++ linux 
Cpp :: check if double is integer c++ 
Cpp :: ue4 ftext c++ 
Cpp :: qimage transformed 
Cpp :: ue4 get socket location c++ 
Cpp :: C++ Fahrenheit to Celsius 
Cpp :: time measurement c++ 
Cpp :: input pdf latex 
Cpp :: c++ throw exception 
Cpp :: differency between c++ std and stl 
Cpp :: distinct colors cses solution 
Cpp :: taking input from user in array in c++ 
Cpp :: oncomponentbeginoverlap ue4 c++ 
Cpp :: how to return 2d array from function c++ 
Cpp :: rank() in c++ 
Cpp :: how to loop a 2 dimensional vector in c++ starting from second element 
Cpp :: time delay in c++ 
Cpp :: c++ check first character of string 
Cpp :: malloc in c++ 
Cpp :: unordered_map header file c++ 
Cpp :: C++ switch cases 
Cpp :: c++ count number of element in vector 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =