#include <stdio.h>
#include <windows.h>
#include <iostream>
#include <sstream>
using namespace std;
template<typename T>
std::string to_string( const T & Value )
{
// utiliser un flux de sortie pour créer la chaîne
std::ostringstream oss;
// écrire la valeur dans le flux
oss << Value;
// renvoyer une string
return oss.str();
}
int main()
{
std::string sIpText;
std::string sIpCaption;
LPCTSTR IpText;
LPCTSTR IpCaption;
UINT uType;
char key;
cout << "Message Box Text:" << endl;
cin >> sIpText;
cout << "Message Box Title:" << endl;
cin >> sIpCaption;
cout << "Message Box Type:" << endl;
cout << "(a) Error" << endl;
cout << "(b) Exclamation" << endl;
cout << "(c) Information" << endl;
cout << "(d) Question " << endl;
switch(key)
{
case 'a':
uType = MB_ICONERROR;
break;
case 'b':
uType = MB_ICONEXCLAMATION;
break;
case 'c':
uType = MB_ICONINFORMATION;
break;
case 'd':
uType = MB_ICONQUESTION;
break;
default:
return EXIT_SUCCESS;
break;
}
IpText = to_string(sIpText);
IpCaption = to_string(sIpCaption);
MessageBox(0, IpText, IpCaption, MB_TASKMODAL);
system("PAUSE");
}
Partager