Glad to see that someone is finally implementing this properly :)
@@ -276,7 +324,33 @@ HRESULT WINAPI TaskDialogIndirect(const TASKDIALOGCONFIG *pTaskConfig, int *pnBu
/* Start creating controls */
- controls_add(controls, IDOK, class_button, text_ok, WS_CHILD | WS_VISIBLE, 105, 85, 40, 10);
- if(!STR_EMPTY(pTaskConfig->pszMainInstruction))
- {
RECT rect;
SelectObject(dc_dummy, font_main);
rect = text_get_rect(dc_dummy, pTaskConfig->pszMainInstruction, dialog_width);
controls_add(controls, ID_TEXTMAIN, class_static, pTaskConfig->pszMainInstruction,
WS_CHILD | WS_VISIBLE, 5, dialog_height + 5, rect.right, rect.bottom);
The psz* parameters (e.g. pszMainInstruction) can contain a resource ID instead of a string. (Passing an invalid ID just results in an empty string.)
Right now passing something that is not a string crashes the dialog, which probably should not happen. To get the string if a resource ID has been passed you can use something like
+/* Fills "result" with a pointer to the string specified by "text", which may be a resource identifier. */ +static HRESULT TASKDIALOG_GetText(const WCHAR *text, HINSTANCE instance, const WCHAR **result) +{ + if (IS_INTRESOURCE(text)) + { + SetLastError(S_OK); + LoadStringW(instance, LOWORD(text), (LPWSTR)result, 0); + return HRESULT_FROM_WIN32(GetLastError()); + } + else + { + *result = text; + return S_OK; + } +}
Right now passing something that is not a string crashes the dialog, which probably should not happen. To get the string if a resource ID has been passed you can use something like
Thanks, probably should have added this already, or at least note it. It was on my todo for a while, then I decided to first get the dialog working properly.
I wanted to get a simple implementation in first, I'm still missing a lot of important features, but it should be a good enough replacement for the solution we currently have. Should I add this feature into this patchset, or is it ok if I add it once I got this upstream?
Regards, Fabian Maurer
Am Friday, 24. February 2017 schrieb Fabian Maurer:
Right now passing something that is not a string crashes the dialog, which probably should not happen. To get the string if a resource ID has been passed you can use something like
Thanks, probably should have added this already, or at least note it. It was on my todo for a while, then I decided to first get the dialog working properly.
That's what I suspected :) In my (irrelevant) opinion, it would be fine to leave the text empty in this special case for now, but it should not crash. You could do e.g. "if (!IS_INTRESOURCE(...) && !STR_EMPTY(...))".
That's what I suspected :) In my (irrelevant) opinion, it would be fine to leave the text empty in this special case for now, but it should not crash. You could do e.g. "if (!IS_INTRESOURCE(...) && !STR_EMPTY(...))".
Good idea, I'll do it like that.
Regards, Fabian Maurer