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; + } +}