Skip to content

Instantly share code, notes, and snippets.

@starius starius/g8.diff
Created Jul 20, 2016

Embed
What would you like to do?
diff --git a/windows/stddialogs.cpp b/windows/stddialogs.cpp
index 1111111..2222222 100644
--- a/windows/stddialogs.cpp
+++ b/windows/stddialogs.cpp
@@ -102,15 +102,30 @@ char *uiSaveFile(uiWindow *parent)
// TODO switch to TaskDialogIndirect()?
+typedef HRESULT (*WINAPI Tfv_TaskDialog)(_In_opt_ HWND hwndOwner, _In_opt_ HINSTANCE hInstance, _In_opt_ PCWSTR pszWindowTitle, _In_opt_ PCWSTR pszMainInstruction, _In_opt_ PCWSTR pszContent, TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons, _In_opt_ PCWSTR pszIcon, int *pnButton);
+Tfv_TaskDialog fv_TaskDialog = NULL;
+
static void msgbox(HWND parent, const char *title, const char *description, TASKDIALOG_COMMON_BUTTON_FLAGS buttons, PCWSTR icon)
{
WCHAR *wtitle, *wdescription;
HRESULT hr;
+ if (fv_TaskDialog == NULL) {
+ fv_TaskDialog = reinterpret_cast<Tfv_TaskDialog>(
+ GetProcAddress(
+ GetModuleHandle(L"comctl32.dll"),
+ "TaskDialog"
+ )
+ );
+ if (fv_TaskDialog == NULL) {
+ logHRESULT(L"error loading TaskDialog function", hr);
+ }
+ }
+
wtitle = toUTF16(title);
wdescription = toUTF16(description);
- hr = TaskDialog(parent, NULL, NULL, wtitle, wdescription, buttons, icon, NULL);
+ hr = fv_TaskDialog(parent, NULL, NULL, wtitle, wdescription, buttons, icon, NULL);
if (hr != S_OK)
logHRESULT(L"error showing task dialog", hr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.