Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ShowTaskDialog(std::string& msg, std::string& title, PCWSTR icon) {
- TaskDialogIndirectFunc TheTaskDialogIndirectFunc;
- HINSTANCE hInstLibrary = LoadLibrary(L"comctl32.dll");
- TheTaskDialogIndirectFunc = (TaskDialogIndirectFunc)GetProcAddress(hInstLibrary, "TaskDialogIndirect");
- if (TheTaskDialogIndirectFunc != NULL) {
- // The Text after the first \n is placed at the content area of the
- // TaskDialog
- size_t pos = msg.find_first_of('\n');
- std::string content = "";
- if (pos == msg.length() - 1) {
- msg.resize(pos);
- }
- else if (pos != std::string::npos) {
- content = msg.substr(pos + 1);
- msg = msg.substr(0, pos);
- }
- #ifdef UNICODE
- std::wstring windowTitle = s2ws(title);
- std::wstring mainInstruction = s2ws(msg);
- std::wstring wcontent = s2ws(content);
- #else
- std::string windowTitle = title;
- std::string mainInstruction = msg;
- #endif
- // Prepare the Dialog
- TASKDIALOGCONFIG config;
- memset(&config, '\0', sizeof(config));
- config.cbSize = sizeof(config);
- config.hwndParent = GetHwnd();
- config.dwFlags = TDF_POSITION_RELATIVE_TO_WINDOW;
- config.pszWindowTitle = windowTitle.c_str();
- config.pszMainIcon = icon;
- config.pszMainInstruction = mainInstruction.c_str();
- config.pszContent = wcontent.c_str();
- TheTaskDialogIndirectFunc(&config, NULL, NULL, NULL);
- }
- FreeLibrary(hInstLibrary);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement