mirror of
				https://github.com/cmderdev/cmder.git
				synced 2025-11-01 01:42:17 +08:00 
			
		
		
		
	switch to taskdialog
This commit is contained in:
		| @@ -9,6 +9,7 @@ | |||||||
| #include <iostream> | #include <iostream> | ||||||
|  |  | ||||||
| #pragma comment(lib, "Shlwapi.lib") | #pragma comment(lib, "Shlwapi.lib") | ||||||
|  | #pragma comment(lib, "comctl32.lib") | ||||||
| #pragma warning( disable : 4091 ) | #pragma warning( disable : 4091 ) | ||||||
|  |  | ||||||
| #ifndef UNICODE | #ifndef UNICODE | ||||||
| @@ -29,6 +30,39 @@ | |||||||
|  |  | ||||||
| #define FAIL_ON_ERROR(x) { DWORD ec; if ((ec = (x)) != ERROR_SUCCESS) { ShowErrorAndExit(ec, __WFUNCTION__, __LINE__); } } | #define FAIL_ON_ERROR(x) { DWORD ec; if ((ec = (x)) != ERROR_SUCCESS) { ShowErrorAndExit(ec, __WFUNCTION__, __LINE__); } } | ||||||
|  |  | ||||||
|  | void TaskDialogOpen( PCWSTR mainStr, PCWSTR contentStr ) | ||||||
|  | { | ||||||
|  |  | ||||||
|  | 	HRESULT hr = NULL; | ||||||
|  |  | ||||||
|  | 	TASKDIALOGCONFIG tsk = {sizeof(tsk)}; | ||||||
|  |  | ||||||
|  | 	HWND hOwner = NULL; | ||||||
|  | 	HINSTANCE hInstance = GetModuleHandle(NULL); | ||||||
|  | 	PCWSTR tskTitle = MAKEINTRESOURCE(IDS_TITLE); | ||||||
|  |  | ||||||
|  | 	tsk.hInstance = hInstance; | ||||||
|  | 	tsk.pszMainIcon = MAKEINTRESOURCE(IDI_CMDER); | ||||||
|  | 	tsk.pszWindowTitle = tskTitle; | ||||||
|  | 	tsk.pszMainInstruction = mainStr;  | ||||||
|  | 	tsk.pszContent = contentStr; | ||||||
|  |  | ||||||
|  | 	TASKDIALOG_BUTTON btns[1] = { | ||||||
|  | 		{ IDOK,     L"OK" } | ||||||
|  | 	}; | ||||||
|  |  | ||||||
|  | 	tsk.dwFlags        = TDF_ALLOW_DIALOG_CANCELLATION|TDF_ENABLE_HYPERLINKS; | ||||||
|  | 	tsk.pButtons       = btns; | ||||||
|  | 	tsk.cButtons       = _countof(btns); | ||||||
|  |  | ||||||
|  | 	tsk.hwndParent     = hOwner; | ||||||
|  |  | ||||||
|  | 	int selectedButtonId = IDOK; | ||||||
|  |  | ||||||
|  | 	hr = TaskDialogIndirect( &tsk, &selectedButtonId, NULL, NULL ); | ||||||
|  |  | ||||||
|  | } | ||||||
|  |  | ||||||
| void ShowErrorAndExit(DWORD ec, const wchar_t * func, int line) | void ShowErrorAndExit(DWORD ec, const wchar_t * func, int line) | ||||||
| { | { | ||||||
| 	wchar_t * buffer; | 	wchar_t * buffer; | ||||||
| @@ -465,7 +499,7 @@ cmderOptions GetOption() | |||||||
| 			LoadString(hMod, IDS_SWITCHES, validOptions, 512); | 			LoadString(hMod, IDS_SWITCHES, validOptions, 512); | ||||||
|  |  | ||||||
| 			// display list of valid options on unrecognized parameter | 			// display list of valid options on unrecognized parameter | ||||||
| 			MessageBox(NULL, validOptions, MB_TITLE, MB_OK); | 			TaskDialogOpen( L"Unrecognized parameter.", validOptions ); | ||||||
| 			cmderOptions.error = true; | 			cmderOptions.error = true; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -4,9 +4,9 @@ | |||||||
|  |  | ||||||
| STRINGTABLE | STRINGTABLE | ||||||
| { | { | ||||||
| 	IDS_TITLE             L"Cmder Launcher" | 	IDS_TITLE             "Cmder Launcher" | ||||||
| 	 | 	 | ||||||
| 	IDS_SWITCHES          L"Unrecognized parameter.\n\nValid options:\n\n    /c [CMDER User Root Path]\n\n    /task [ConEmu Task Name]\n\n    [/start [Start in Path] | [Start in Path]]\n\n    /single\n\nor\n\n    /register [USER | ALL]\n\nor\n\n    /unregister [USER | ALL]\n" | 	IDS_SWITCHES          L"Valid options:\n\n    /c [CMDER User Root Path]\n    /task [ConEmu Task Name]\n    [/start [Start in Path] | [Start in Path]]\n    /single\n\nor, either:\n    /register [USER | ALL]\n    /unregister [USER | ALL]" | ||||||
| } | } | ||||||
|  |  | ||||||
| ///////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////// | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user