mirror of
https://github.com/cmderdev/cmder.git
synced 2024-11-10 17:59:11 +08:00
Merge pull request #2746 from DRSDavidSoft/taskdialog
Use TaskDialog instead of MessageBox (Fixes Builds)
This commit is contained in:
commit
0f490fdb61
@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 14
|
# Visual Studio 14
|
||||||
VisualStudioVersion = 14.0.23107.0
|
VisualStudioVersion = 14.0.23107.0
|
||||||
|
@ -22,13 +22,12 @@
|
|||||||
<ProjectGuid>{4A8485A5-B7DD-4C44-B7F6-3E2765DD0CD3}</ProjectGuid>
|
<ProjectGuid>{4A8485A5-B7DD-4C44-B7F6-3E2765DD0CD3}</ProjectGuid>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<RootNamespace>CmderLauncher</RootNamespace>
|
<RootNamespace>CmderLauncher</RootNamespace>
|
||||||
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v141_xp</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
@ -36,7 +35,7 @@
|
|||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v140</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
@ -95,6 +94,7 @@
|
|||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<!-- <AdditionalDependencies>comctl32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies> -->
|
||||||
</Link>
|
</Link>
|
||||||
<Manifest>
|
<Manifest>
|
||||||
<AdditionalManifestFiles>src/app.manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>
|
<AdditionalManifestFiles>src/app.manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>
|
||||||
@ -121,6 +121,7 @@
|
|||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<!-- <AdditionalDependencies>comctl32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies> -->
|
||||||
</Link>
|
</Link>
|
||||||
<Manifest>
|
<Manifest>
|
||||||
<AdditionalManifestFiles>src/app.manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>
|
<AdditionalManifestFiles>src/app.manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>
|
||||||
@ -176,7 +177,7 @@
|
|||||||
</PostBuildEvent>
|
</PostBuildEvent>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="src\Resource.rc">
|
<ResourceCompile Include="src\resource.rc">
|
||||||
<FileType>RC</FileType>
|
<FileType>RC</FileType>
|
||||||
</ResourceCompile>
|
</ResourceCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -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
|
||||||
@ -31,6 +32,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;
|
||||||
@ -673,16 +707,25 @@ cmderOptions GetOption()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox(NULL, L"Unrecognized parameter.\n\nValid options:\n\n /c [CMDER User Root Path]\n\n /task [ConEmu Task Name]\n\n /icon [CMDER Icon Path]\n\n [/start [Start in Path] | [Start in Path]]\n\n /single\n\n /m\n\n /x [ConEmu extra arguments]\n\nor\n\n /register [USER | ALL]\n\nor\n\n /unregister [USER | ALL]\n", MB_TITLE, MB_OK);
|
|
||||||
cmderOptions.error = true;
|
cmderOptions.error = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox(NULL, L"Unrecognized parameter.\n\nValid options:\n\n /c [CMDER User Root Path]\n\n /task [ConEmu Task Name]\n\n /icon [CMDER Icon Path]\n\n [/start [Start in Path] | [Start in Path]]\n\n /single\n\n /m\n\n /x [ConEmu extra arguments]\n\nor\n\n /register [USER | ALL]\n\nor\n\n /unregister [USER | ALL]\n", MB_TITLE, MB_OK);
|
|
||||||
cmderOptions.error = true;
|
cmderOptions.error = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmderOptions.error == true)
|
||||||
|
{
|
||||||
|
wchar_t validOptions[512];
|
||||||
|
HMODULE hMod = GetModuleHandle(NULL);
|
||||||
|
LoadString(hMod, IDS_SWITCHES, validOptions, 512);
|
||||||
|
|
||||||
|
// display list of valid options on unrecognized parameter
|
||||||
|
TaskDialogOpen( L"Unrecognized parameter.", validOptions );
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalFree(szArgList);
|
LocalFree(szArgList);
|
||||||
|
Binary file not shown.
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "version.rc2"
|
#include "version.rc2"
|
||||||
|
#include "strings.rc2"
|
||||||
|
|
||||||
#define APSTUDIO_READONLY_SYMBOLS
|
#define APSTUDIO_READONLY_SYMBOLS
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
12
launcher/src/strings.rc2
Executable file
12
launcher/src/strings.rc2
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Corresponding ids should be defined in `resource.h` file.
|
||||||
|
|
||||||
|
STRINGTABLE
|
||||||
|
{
|
||||||
|
IDS_TITLE "Cmder Launcher"
|
||||||
|
|
||||||
|
IDS_SWITCHES L"Valid options:\n\n /c [CMDER User Root Path]\n /task [ConEmu Task Name]\n /icon [CMDER Icon Path]\n [/start [Start in Path] | [Start in Path]]\n /single\n /m\n /x [ConEmu extra arguments]\n\nor, either:\n /register [USER | ALL]\n /unregister [USER | ALL]"
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
Loading…
Reference in New Issue
Block a user