I need to notify a user about some information using message box in a notification app, but it shouldn't block the program (input and output in console).
I was thinking about using separate thread for every notification, but it seems to take too much resources. Maybe in this case it isn't so?
My example code is like this:
#include <iostream>
#include <string>
#include <windows.h>
void showMessage(std::string message)
{
std::wstring widestr = std::wstring(message.begin(), message.end());
const wchar_t* widecstr = widestr.c_str();
MessageBoxW(NULL, (LPCWSTR)(widecstr), (LPCWSTR)L"Notification", NULL);
}
int main()
{
while(1)
{
std::string str;
std::cin >> str;
if(str == "0")
break;
showMessage(str);
}
return 0;
}
What should I add to it? Thanks!