Cant get message box to work

#include <iostream>
#include <windows.h>
using namespace std;


int main ( int argc, char ^argv[])
{
MessageBox(NULL "hello world \nThis is the 2nd line." "hello" MB_OKYESCANCEL);

cin.get();
return 0;
}


i cant seem to get it to work

errors that i recieve
6 27 C:\Users\Josh\Desktop\C++\DialogBox.cpp [Error] expected ',' or '...' before '^' token
6 5 C:\Users\Josh\Desktop\C++\DialogBox.cpp [Warning] second argument of 'int main(int, char)' should be 'char **' [-Wmain]
C:\Users\Josh\Desktop\C++\DialogBox.cpp In function 'int main(int, char)':
8 18 C:\Users\Josh\Desktop\C++\DialogBox.cpp [Error] expected ')' before string constant
8 69 C:\Users\Josh\Desktop\C++\DialogBox.cpp [Error] too few arguments to function 'int MessageBoxA(HWND, LPCSTR, LPCSTR, UINT)'
72 0 c:\program files (x86)\dev-cpp\mingw64\x86_64-w64-mingw32\include\windows.h In file included from c:\program files (x86)\dev-cpp\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/windows.h
2 C:\Users\Josh\Desktop\C++\DialogBox.cpp from C:\Users\Josh\Desktop\C++\DialogBox.cpp
3013 25 c:\program files (x86)\dev-cpp\mingw64\x86_64-w64-mingw32\include\winuser.h [Note] declared here

Last edited on
You are trying to compile CLI/C++ code in C++ compiler.
CLI/C++ is different language from C++, althrough it looks similar to it.
Also you have missed commas in function call
Try:
1
2
3
4
5
6
7
8
9
#include <iostream>
#include <windows.h>
using namespace std;

int main ( int argc, char* argv[])
{
    MessageBox(NULL, "hello world \nThis is the 2nd line.", "hello", MB_OKYESCANCEL);
    cin.get();
}

Last edited on
wow you are so right lol thanks a bunch
so i added a result to open a webpage but it wont open


#include <iostream>
#include <windows.h>
using namespace std;

int main(int argc, char* argv[])
{
int result;

result = MessageBox(NULL, "Would you like to play a GAME!\n.", "GAME", MB_YESNOCANCEL);

if(result == IDYES)
{
cout<<"you clicked yes\n";



ShellExecute(NULL, "open", "http://www.facebook.com", NULL, NULL, SW_SHOWNORMAL);

}
else
{
cout<<"you should click cancel\n";

}

cin.get();

return 0;
}
Last edited on
Topic archived. No new replies allowed.