5 std::wstring stringToWString(
const std::string& str) {
6 if (str.empty())
return std::wstring();
8 int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], (
int)str.size(), NULL, 0);
9 std::wstring wstrTo(size_needed, 0);
10 MultiByteToWideChar(CP_UTF8, 0, &str[0], (
int)str.size(), &wstrTo[0], size_needed);
17 std::wstring wTitle = stringToWString(title);
18 std::wstring wMessage = stringToWString(message);
19 MessageBoxW(
nullptr, wMessage.c_str(), wTitle.c_str(), MB_OK | MB_ICONERROR);
21 std::cerr <<
"[ERROR] " << title <<
": " << message << std::endl;
27 std::wstring wTitle = stringToWString(title);
28 std::wstring wMessage = stringToWString(message);
29 MessageBoxW(
nullptr, wMessage.c_str(), wTitle.c_str(), MB_OK | MB_ICONWARNING);
31 std::cerr <<
"[WARNING] " << title <<
": " << message << std::endl;
37 std::wstring wTitle = stringToWString(title);
38 std::wstring wMessage = stringToWString(message);
39 int result = MessageBoxW(
nullptr, wMessage.c_str(), wTitle.c_str(), MB_YESNO | MB_ICONQUESTION);
40 return result == IDYES;
42 std::cout <<
"[CONFIRM] " << title <<
": " << message <<
" (y/n): ";
45 return response ==
'y' || response ==
'Y';
51 std::wstring wTitle = stringToWString(title);
52 std::wstring wMessage = stringToWString(message);
53 MessageBoxW(
nullptr, wMessage.c_str(), wTitle.c_str(), MB_OK | MB_ICONINFORMATION);
55 std::cout <<
"[INFO] " << title <<
": " << message << std::endl;
void ShowErrorDialog(const std::string &title, const std::string &message)
显示错误对话框
bool ShowConfirmDialog(const std::string &title, const std::string &message)
显示确认对话框
void ShowInfoDialog(const std::string &title, const std::string &message)
显示信息对话框
void ShowWarningDialog(const std::string &title, const std::string &message)
显示警告对话框