void CNewTreeConflictEditorDlg::DoModal(HWND parent) { CTSVNPath path = m_conflictInfo->GetPath(); CString sDialogTitle; sDialogTitle.LoadString(IDS_PROC_EDIT_TREE_CONFLICTS); sDialogTitle = CCommonAppUtils::FormatWindowTitle(path.GetUIPathString(), sDialogTitle); if (!m_conflictInfo->GetTreeResolutionOptions(m_options)) { m_conflictInfo->ShowErrorDialog(parent); } CString sMainInstruction = m_conflictInfo->GetIncomingChangeSummary(); CString sContent = m_conflictInfo->GetLocalChangeSummary(); int button; for (SVNConflictOptions::const_iterator it = m_options.begin(); it != m_options.end(); ++it) { svn_client_conflict_option_id_t id = (*it)->GetId(); CString optLabel = (*it)->GetLabel(); CString optDescription((*it)->GetDescription()); optDescription.SetAt(0, towupper(optDescription[0])); AddCommandButton(100 + id, optLabel + L"\n" + optDescription); } TASKDIALOGCONFIG taskConfig = {0}; taskConfig.cbSize = sizeof(taskConfig); taskConfig.hwndParent = parent; taskConfig.dwFlags = TDF_USE_COMMAND_LINKS; taskConfig.lpCallbackData = (LONG_PTR) this; taskConfig.pfCallback = TaskDialogCallback; taskConfig.pszWindowTitle = sDialogTitle; taskConfig.pszMainInstruction = sMainInstruction; taskConfig.pszContent = sContent; taskConfig.pButtons = &m_buttons.front(); taskConfig.cButtons = (int) m_buttons.size(); taskConfig.dwCommonButtons = TDCBF_CANCEL_BUTTON; TaskDialogIndirect(&taskConfig, &button, NULL, NULL); if (button == IDCANCEL) { m_bCancelled = true; } }
BOOLEAN DialogPromptExit( _In_ HWND hwndDlg ) { INT buttonPressed = 0; TASKDIALOGCONFIG config = { sizeof(TASKDIALOGCONFIG) }; config.hwndParent = hwndDlg; config.hInstance = PhInstanceHandle; config.dwFlags = TDF_POSITION_RELATIVE_TO_WINDOW; config.nDefaultButton = IDNO; config.dwCommonButtons = TDCBF_YES_BUTTON | TDCBF_NO_BUTTON; config.pszMainIcon = TD_WARNING_ICON; config.pszMainInstruction = L"Exit Setup"; config.pszWindowTitle = PhApplicationName; config.pszContent = L"Are you sure you want to cancel the Setup?"; TaskDialogIndirect(&config, &buttonPressed, NULL, NULL); return buttonPressed == IDNO; }
BOOLEAN DialogPromptExit( _In_ HWND hwndDlg ) { if (WindowsVersion > WINDOWS_VISTA && TaskDialogIndirect) { INT nButtonPressed = 0; TASKDIALOGCONFIG tdConfig = { sizeof(TASKDIALOGCONFIG) }; tdConfig.hwndParent = hwndDlg; tdConfig.hInstance = PhLibImageBase; tdConfig.dwFlags = TDF_POSITION_RELATIVE_TO_WINDOW; tdConfig.nDefaultButton = IDNO; tdConfig.dwCommonButtons = TDCBF_YES_BUTTON | TDCBF_NO_BUTTON; tdConfig.pszMainIcon = TD_WARNING_ICON; tdConfig.pszMainInstruction = L"Exit Setup"; tdConfig.pszWindowTitle = PhApplicationName; tdConfig.pszContent = L"Are you sure you want to cancel the Setup?"; TaskDialogIndirect(&tdConfig, &nButtonPressed, NULL, NULL); return nButtonPressed == IDNO; } else { MSGBOXPARAMS mbParams = { sizeof(MSGBOXPARAMS) }; mbParams.hwndOwner = hwndDlg; mbParams.hInstance = PhLibImageBase; mbParams.lpszText = L"Are you sure you want to cancel the Setup?"; mbParams.lpszCaption = PhApplicationName; mbParams.dwStyle = MB_YESNO | MB_ICONEXCLAMATION; // | MB_USERICON; //params.lpszIcon = MAKEINTRESOURCE(IDI_ICON1); return MessageBoxIndirect(&mbParams) == IDNO; } }
VOID SetupShowUpdateDialog( VOID ) { PVOID context; TASKDIALOGCONFIG config; PH_AUTO_POOL autoPool; memset(&config, 0, sizeof(TASKDIALOGCONFIG)); PhInitializeAutoPool(&autoPool); context = CreateUpdateContext(); config.cbSize = sizeof(TASKDIALOGCONFIG); config.dwFlags = TDF_POSITION_RELATIVE_TO_WINDOW; config.dwCommonButtons = TDCBF_CANCEL_BUTTON; config.pszWindowTitle = PhApplicationName; config.pfCallback = TaskDialogBootstrapCallback; config.lpCallbackData = (LONG_PTR)context; TaskDialogIndirect(&config, NULL, NULL, NULL); PhDeleteAutoPool(&autoPool); }
VOID NTAPI MenuItemCallback( _In_opt_ PVOID Parameter, _In_opt_ PVOID Context ) { PPH_PLUGIN_MENU_ITEM menuItem = Parameter; switch (menuItem->Id) { case ENABLE_SERVICE_VIRUSTOTAL: { ULONG scanningEnabled = !VirusTotalScanningEnabled; PhSetIntegerSetting(SETTING_NAME_VIRUSTOTAL_SCAN_ENABLED, scanningEnabled); if (VirusTotalScanningEnabled != scanningEnabled) { INT result = IDOK; TASKDIALOGCONFIG config; memset(&config, 0, sizeof(TASKDIALOGCONFIG)); config.cbSize = sizeof(TASKDIALOGCONFIG); config.dwFlags = TDF_USE_HICON_MAIN | TDF_ALLOW_DIALOG_CANCELLATION; config.dwCommonButtons = TDCBF_YES_BUTTON | TDCBF_NO_BUTTON; config.hwndParent = menuItem->OwnerWindow; config.hMainIcon = PH_LOAD_SHARED_ICON_LARGE(PhInstanceHandle, MAKEINTRESOURCE(PHAPP_IDI_PROCESSHACKER)); config.cxWidth = 180; config.pszWindowTitle = L"Process Hacker - VirusTotal"; config.pszMainInstruction = L"VirusTotal scanning requires a restart of Process Hacker."; config.pszContent = L"Do you want to restart Process Hacker now?"; if (SUCCEEDED(TaskDialogIndirect(&config, &result, NULL, NULL)) && result == IDYES) { ProcessHacker_PrepareForEarlyShutdown(PhMainWndHandle); PhShellProcessHacker( PhMainWndHandle, L"-v", SW_SHOW, 0, PH_SHELL_APP_PROPAGATE_PARAMETERS | PH_SHELL_APP_PROPAGATE_PARAMETERS_IGNORE_VISIBILITY, 0, NULL ); ProcessHacker_Destroy(PhMainWndHandle); } DestroyIcon(config.hMainIcon); } } break; case MENUITEM_VIRUSTOTAL_UPLOAD: UploadToOnlineService(menuItem->Context, MENUITEM_VIRUSTOTAL_UPLOAD); break; case MENUITEM_VIRUSTOTAL_UPLOAD_SERVICE: UploadServiceToOnlineService(menuItem->Context, MENUITEM_VIRUSTOTAL_UPLOAD_SERVICE); break; case MENUITEM_JOTTI_UPLOAD: UploadToOnlineService(menuItem->Context, MENUITEM_JOTTI_UPLOAD); break; case MENUITEM_JOTTI_UPLOAD_SERVICE: UploadServiceToOnlineService(menuItem->Context, MENUITEM_JOTTI_UPLOAD_SERVICE); break; case MENUITEM_HYBRIDANALYSIS_UPLOAD: UploadToOnlineService(menuItem->Context, MENUITEM_HYBRIDANALYSIS_UPLOAD); break; case MENUITEM_HYBRIDANALYSIS_UPLOAD_SERVICE: UploadServiceToOnlineService(menuItem->Context, MENUITEM_HYBRIDANALYSIS_UPLOAD_SERVICE); break; case MENUITEM_VIRUSTOTAL_UPLOAD_FILE: case MENUITEM_HYBRIDANALYSIS_UPLOAD_FILE: { static PH_FILETYPE_FILTER filters[] = { { L"All files (*.*)", L"*.*" } }; PVOID fileDialog; PPH_STRING fileName; fileDialog = PhCreateOpenFileDialog(); PhSetFileDialogFilter(fileDialog, filters, sizeof(filters) / sizeof(PH_FILETYPE_FILTER)); if (PhShowFileDialog(menuItem->Context, fileDialog)) { fileName = PH_AUTO(PhGetFileDialogFileName(fileDialog)); switch (menuItem->Id) { case MENUITEM_VIRUSTOTAL_UPLOAD_FILE: UploadToOnlineService(fileName, MENUITEM_VIRUSTOTAL_UPLOAD); break; case MENUITEM_HYBRIDANALYSIS_UPLOAD_FILE: UploadToOnlineService(fileName, MENUITEM_HYBRIDANALYSIS_UPLOAD); break; } } PhFreeFileDialog(fileDialog); } break; } }
/** * Presents the user with the assertion failed dialog box, and returns the * action that the user chose to perform */ AssertionDialog::EUserAction AssertionDialog::ShowDialog() const { // The buttons that will appear on the assertion dialog const TASKDIALOG_BUTTON cb[] = { { 0, L"Save crash information (default)\nYou can help the developers of " L"this program by e-mailing them this crash information after saving " L"it to your computer" }, { 1, L"Fire up the debugger (advanced)\nTriggers a breakpoint in Visual " L"Studio and jumps to the offending line of code" }, { 2, L"Quit the application\nOh no! We promise not to crash again :(" } }; // Create a dialog to display the assertion information and configure // its options TASKDIALOGCONFIG tc = { 0 }; tc.cbSize = sizeof(tc); tc.hwndParent = mWindowHandle; tc.hInstance = mAppInstance; tc.dwFlags = TDF_USE_HICON_MAIN | TDF_USE_HICON_FOOTER | TDF_EXPAND_FOOTER_AREA | TDF_USE_COMMAND_LINKS; LoadIconWithScaleDown( NULL, MAKEINTRESOURCE(IDI_ERROR), /*IDI_ERROR,*/ GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), &tc.hMainIcon); LoadIconWithScaleDown( NULL, IDI_INFORMATION, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), &tc.hFooterIcon); tc.pszWindowTitle = L"Application Assertion"; tc.pszContent = mMessage.c_str(); tc.pszMainInstruction = L"An internal assertion check has failed"; tc.pszFooter = mExpression.c_str(); tc.cButtons = ARRAYSIZE(cb); tc.pButtons = cb; tc.nDefaultButton = 0; // After all that tedious set up work, we can finally show off our fancy shmancy assertion dialog! int buttonPressed = 0; int commandPressed = 0; BOOL verificationChecked = false; TaskDialogIndirect( &tc, &buttonPressed, &commandPressed, &verificationChecked); // Return which action was selected switch (buttonPressed) { case 0: return EUSERACTION_SAVE; case 1: return EUSERACTION_DEBUG; case 2: return EUSERACTION_QUIT; default: return EUSERACTION_QUIT; } }
DWORD WINAPI DialogThreadEntry(LPVOID lpParam) { int buttonPressed = 0; EXTERNAL_INFO *externalInfo = (PEXTERNAL_INFO)lpParam; TASKDIALOGCONFIG config = {0}; config.cbSize = sizeof(config); config.hInstance = GetModuleHandle(NULL); config.dwCommonButtons = TDCBF_CANCEL_BUTTON; config.pszMainIcon = TD_INFORMATION_ICON; if(externalInfo->langId == 0x0419) config.pszMainInstruction = L"PIN Pad считыватель"; else if(externalInfo->langId == 0x0425) //config.pszMainInstruction = L"Autentige PINPADˇiga"; config.pszMainInstruction = L"PIN Pad kaardilugeja"; else config.pszMainInstruction = L"PIN Pad Reader"; if(externalInfo->pinType == 1) { if(externalInfo->langId == 0x0419) config.pszContent = L"Введите код PIN для идентификации (PIN 1)"; else if(externalInfo->langId == 0x0425) config.pszContent = L"Palun sisestage autoriseerimise PIN (PIN1)"; else config.pszContent = L"Enter PIN for authentication (PIN 1)"; } else if(externalInfo->pinType == 3) { if(externalInfo->langId == 0x0419) config.pszContent = L"Введите код PIN для подписи (PIN 2)"; else if(externalInfo->langId == 0x0425) config.pszContent = L"Palun sisestage digiallkirjastamise PIN (PIN2)"; else config.pszContent = L"Enter PIN for digital signature (PIN 2)"; } else { config.pszContent = L"Enter PIN"; if(externalInfo->langId == 0x0419) config.pszContent = L"Введите PIN код"; else if(externalInfo->langId == 0x0425) config.pszContent = L"Sisestage PIN"; else config.pszContent = L"Enter PIN code"; } config.dwFlags = TDF_EXPAND_FOOTER_AREA | TDF_SHOW_PROGRESS_BAR | TDF_CALLBACK_TIMER | TDF_ENABLE_HYPERLINKS; if(externalInfo->langId == 0x0419) { if(externalInfo->pinType == 1) { config.pszExpandedInformation = L"Данная операция требует сертификат идентификации. Для использования сертификата идентификации введите PIN1 с клавиатуры считывателя."; } else if(externalInfo->pinType == 3) { config.pszExpandedInformation = L"Для данной операцин необходим сертификат подписи. Для использования сертификата подписи введите PIN2 с клавиатуры считывателя."; } } else if(externalInfo->langId == 0x0425) { if(externalInfo->pinType == 1) { config.pszExpandedInformation = L"Valitud tegevuse jaoks on vaja kasutada isikutuvastuse sertifikaati. Sertifikaadi kasutamiseks sisesta PIN1 kaardilugeja sõrmistikult."; } else if(externalInfo->pinType == 3) { config.pszExpandedInformation = L"Valitud tegevuse jaoks on vaja kasutada allkirjastamise sertifikaati. Sertifikaadi kasutamiseks sisesta PIN2 kaardilugeja sõrmistikult."; } } else { if(externalInfo->pinType == 1) { config.pszExpandedInformation = L"Selected action requires authentication certificate. For using authentication certificate enter PIN1 at the reader."; } else if(externalInfo->pinType == 3) { config.pszExpandedInformation = L"Selected action requires digital signature certificate. For using signature certificate enter PIN2 at the reader."; } } config.pfCallback = TaskDialogCallbackProcPinEntry; BOOL bVerification = false; HRESULT res = TaskDialogIndirect(&config, &buttonPressed, NULL, NULL); return 0; }
int cTaskDialog::Run(cWindow& parent, const cTaskDialogSettings& settings) { // Create our task dialog TASKDIALOGCONFIG tdc = { 0 }; tdc.cbSize = sizeof(tdc); tdc.dwFlags = TDF_ALLOW_DIALOG_CANCELLATION; if (settings.bIsCheckBoxTickedInitially) tdc.dwFlags |= TDF_VERIFICATION_FLAG_CHECKED; tdc.dwCommonButtons = (settings.bCloseButtonText ? TDCBF_CLOSE_BUTTON : TDCBF_CANCEL_BUTTON); tdc.hwndParent = parent.GetWindowHandle(); tdc.hInstance = GetHInstance(); //tdc.hMainIcon = hIcon; switch (settings.type) { case cTaskDialogSettings::TYPE::INFORMATION: { tdc.pszMainIcon = TD_INFORMATION_ICON; break; } case cTaskDialogSettings::TYPE::WARNING: { tdc.pszMainIcon = TD_ERROR_ICON; break; } case cTaskDialogSettings::TYPE::ERROR: { tdc.pszMainIcon = TD_ERROR_ICON; break; } }; tdc.pszWindowTitle = settings.sCaption.c_str(); tdc.pszMainInstruction = settings.sInstructions.c_str(); tdc.pszContent = settings.sContent.c_str(); // Add our buttons TASKDIALOG_BUTTON* pButtons = nullptr; const size_t nButtons = settings.items.size(); if (!settings.items.empty()) { tdc.dwFlags |= TDF_USE_COMMAND_LINKS; pButtons = new TASKDIALOG_BUTTON[nButtons]; for (size_t i = 0; i < nButtons; i++) { pButtons[i].nButtonID = settings.items[i].iCommandID; string_t sText(settings.items[i].sText); if (!settings.items[i].sTextDescription.empty()) { sText += TEXT("\n"); sText += settings.items[i].sTextDescription; } const size_t nSize = sText.length() + 1; pButtons[i].pszButtonText = new wchar_t[nSize]; wcscpy_s((wchar_t*)(pButtons[i].pszButtonText), nSize, sText.c_str()); } tdc.pButtons = pButtons; tdc.cButtons = UINT(nButtons); tdc.nDefaultButton = settings.iDefaultItemCommandID; } /*PCWSTR pszExpandedInformation; PCWSTR pszExpandedControlText; PCWSTR pszCollapsedControlText;*/ tdc.pfCallback = _TaskDialogCallbackProc; tdc.lpCallbackData = LONG_PTR(this); if (settings.bIsProgressBarVisible) { tdc.dwFlags |= TDF_CALLBACK_TIMER | TDF_SHOW_PROGRESS_BAR; } // Checkbox if (settings.bIsCheckBoxVisible) { tdc.dwFlags |= TDF_EXPAND_FOOTER_AREA; tdc.pszVerificationText = settings.sCheckBoxTitle.c_str(); } // Run the task dialog int iButton = 0; //BOOL bResult = FALSE; const HRESULT rResult = TaskDialogIndirect(&tdc, &iButton, NULL, nullptr /*&bResult*/); assert(rResult == S_OK); // Clear our window handle hwndWindow = NULL; // Destroy our buttons if (pButtons != nullptr) { for (size_t i = 0; i < nButtons; i++) delete [] pButtons[i].pszButtonText; delete [] pButtons; } // If there was an error then pretend the user cancelled if (rResult != S_OK) iButton = IDCANCEL; // If no valid selection was made then pretend the user cancelled if (iButton < 0) iButton = IDCANCEL; // Return the button that was selected return iButton; }