diff --git a/source/g3d_viewer/main.cpp b/source/g3d_viewer/main.cpp index d64a7ed7c..408d00648 100644 --- a/source/g3d_viewer/main.cpp +++ b/source/g3d_viewer/main.cpp @@ -2080,6 +2080,29 @@ namespace Shared { bool App::OnInit() { SystemFlags::VERBOSE_MODE_ENABLED = false; +#ifdef WIN32 + /*It is recommended that you delay-load ComCtl32.dll (/DelayLoad:ComCtl32.dll) + and that you ensure this code runs before GUI components are loaded. + Otherwise, you may get weird issues, like black backgrounds in icons in image lists.*/ + { + TCHAR dir[MAX_PATH]; + ULONG_PTR ulpActivationCookie = FALSE; + ACTCTX actCtx = + { + sizeof(actCtx), + ACTCTX_FLAG_RESOURCE_NAME_VALID + | ACTCTX_FLAG_SET_PROCESS_DEFAULT + | ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID, + TEXT("shell32.dll"), 0, 0, dir, (LPCTSTR) 124 + }; + UINT cch = GetSystemDirectory(dir, sizeof(dir) / sizeof(*dir)); + if (cch >= sizeof(dir) / sizeof(*dir)) { + return FALSE; /*shouldn't happen*/ + } + dir[cch] = TEXT('\0'); + ActivateActCtx(CreateActCtx(&actCtx), &ulpActivationCookie); + } +#endif #if defined(wxMAJOR_VERSION) && defined(wxMINOR_VERSION) && defined(wxRELEASE_NUMBER) && defined(wxSUBRELEASE_NUMBER) printf("Using wxWidgets version [%d.%d.%d.%d]\n", wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER, wxSUBRELEASE_NUMBER); diff --git a/source/map_editor/main.cpp b/source/map_editor/main.cpp index 767e65906..40022e540 100644 --- a/source/map_editor/main.cpp +++ b/source/map_editor/main.cpp @@ -1628,6 +1628,30 @@ wxT("Help")).ShowModal(); SystemFlags::VERBOSE_MODE_ENABLED = false; SystemFlags::ENABLE_THREADED_LOGGING = false; +#ifdef WIN32 + /*It is recommended that you delay-load ComCtl32.dll (/DelayLoad:ComCtl32.dll) + and that you ensure this code runs before GUI components are loaded. + Otherwise, you may get weird issues, like black backgrounds in icons in image lists.*/ + { + TCHAR dir[MAX_PATH]; + ULONG_PTR ulpActivationCookie = FALSE; + ACTCTX actCtx = + { + sizeof(actCtx), + ACTCTX_FLAG_RESOURCE_NAME_VALID + | ACTCTX_FLAG_SET_PROCESS_DEFAULT + | ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID, + TEXT("shell32.dll"), 0, 0, dir, (LPCTSTR) 124 + }; + UINT cch = GetSystemDirectory(dir, sizeof(dir) / sizeof(*dir)); + if (cch >= sizeof(dir) / sizeof(*dir)) { + return FALSE; /*shouldn't happen*/ + } + dir[cch] = TEXT('\0'); + ActivateActCtx(CreateActCtx(&actCtx), &ulpActivationCookie); + } +#endif + string fileparam; if (argc == 2) { if (argv[1][0] == '-') { // any flag gives help and exits program.