diff --git a/deps/libui/win32/stddialogs.cpp b/deps/libui/win32/stddialogs.cpp index 60f9f68ec2..07678542c0 100644 --- a/deps/libui/win32/stddialogs.cpp +++ b/deps/libui/win32/stddialogs.cpp @@ -1,21 +1,26 @@ -// 22 may 2015 +/* 22 may 2015 */ +#include #include "uipriv_windows.hpp" #ifndef _MSC_VER #include "winextra.h" #endif -// TODO document all this is what we want -// TODO do the same for font and color buttons +static dylib_t comctl_dll_handle = NULL; /* Handle to Comctl32 */ -// notes: -// - FOS_SUPPORTSTREAMABLEITEMS doesn't seem to be supported on windows vista, or at least not with the flags we use -// - even with FOS_NOVALIDATE the dialogs will reject invalid filenames (at least on Vista, anyway) -// - lack of FOS_NOREADONLYRETURN doesn't seem to matter on Windows 7 +/* + * TODO document all this is what we want + * TODO do the same for font and color buttons -// TODO -// - http://blogs.msdn.com/b/wpfsdk/archive/2006/10/26/uncommon-dialogs--font-chooser-and-color-picker-dialogs.aspx -// - when a dialog is active, tab navigation in other windows stops working -// - when adding uiOpenFolder(), use IFileDialog as well - https://msdn.microsoft.com/en-us/library/windows/desktop/bb762115%28v=vs.85%29.aspx + * notes: + * - FOS_SUPPORTSTREAMABLEITEMS doesn't seem to be supported on windows vista, or at least not with the flags we use + * - even with FOS_NOVALIDATE the dialogs will reject invalid filenames (at least on Vista, anyway) + * - lack of FOS_NOREADONLYRETURN doesn't seem to matter on Windows 7 + + * TODO + * - http://blogs.msdn.com/b/wpfsdk/archive/2006/10/26/uncommon-dialogs--font-chooser-and-color-picker-dialogs.aspx + * - when a dialog is active, tab navigation in other windows stops working + * - when adding uiOpenFolder(), use IFileDialog as well - https://msdn.microsoft.com/en-us/library/windows/desktop/bb762115%28v=vs.85%29.aspx + */ #define windowHWND(w) ((HWND) uiControlHandle(uiControl(w))) @@ -104,19 +109,28 @@ char *uiSaveFile(uiWindow *parent) } // TODO switch to TaskDialogIndirect()? +typedef HRESULT (WINAPI *TaskDialogProc)(HWND hwndParent,HINSTANCE hInstance,PCWSTR pszWindowTitle,PCWSTR pszMainInstruction,PCWSTR pszContent,TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons,PCWSTR pszIcon,int *pnButton); +static TaskDialogProc task_dialog_proc; -static void msgbox(HWND parent, const char *title, const char *description, TASKDIALOG_COMMON_BUTTON_FLAGS buttons, PCWSTR icon) +static void msgbox(HWND parent, const char *title, const char *description, + TASKDIALOG_COMMON_BUTTON_FLAGS buttons, PCWSTR icon) { - WCHAR *wtitle, *wdescription; - HRESULT hr; + HRESULT hr = E_FAIL; + WCHAR *wtitle = toUTF16(title); + WCHAR *wdescription = toUTF16(description); - wtitle = toUTF16(title); - wdescription = toUTF16(description); + comctl_dll_handle = dylib_load("comctl32.lib"); + + task_dialog_proc = (TaskDialogProc)GetProcAddress((HINSTANCE)comctl_dll_handle, "TaskDialog"); + + if (task_dialog_proc) + hr = task_dialog_proc(parent, NULL, NULL, wtitle, wdescription, buttons, icon, NULL); - hr = TaskDialog(parent, NULL, NULL, wtitle, wdescription, buttons, icon, NULL); if (hr != S_OK) logHRESULT(L"error showing task dialog", hr); + dylib_close(comctl_dll_handle); + uiFree(wdescription); uiFree(wtitle); }