[3/5] comctl32: Implement TaskDialogIndirect as a custom dialog box (try 2)

Joachim Priesner joachim.priesner at web.de
Tue Feb 24 09:15:35 CST 2015


Am Dienstag, 24. Februar 2015 schrieb Alexandre Julliard:
> Nikolay Sivov <bunglehead at gmail.com> writes:
> 
> > On 24.02.2015 17:37, Joachim Priesner wrote:
> >> Am Dienstag, 24. Februar 2015 schrieb Nikolay Sivov:
> >>> On 23.02.2015 15:42, Joachim Priesner wrote:
> >>>> +    if (IS_INTRESOURCE(text))
> >>>> +    {
> >>>> +        SetLastError(S_OK);
> >>>> +        LoadStringW(instance, LOWORD(text), (LPWSTR)result, 0);
> >>>> +        return HRESULT_FROM_WIN32(GetLastError());
> >>>> +    }
> >>>
> >>> You don't need SetLastError(), especially not with HRESULT value. And
> >>> GetLastError() should only be used when LoadStringW() fails.
> >>
> >> Thanks for the feedback, again. The rationale behind SetLastError is that the following three cases can occur:
> >>   1) LoadStringW succeeds, string length > 0 => return value > 0
> >>   2) LoadStringW succeeds, string length == 0 => return value 0
> >>   3) LoadStringW fails => return value 0, error code available via GetLastError.
> >>
> >> Because LastError is not modified in case 2), I have to set it to S_OK beforehand in order to distinguish between 2) and 3). Does that make sense?
> >>
> >
> > Ok, what happens on windows if resource length is 0? If it still works
> > and text is simply empty you can detect a failure another way - by
> > testing returned resource pointer (I'd expect NULL if resource id was
> > not found), and in that case use last error.
> 
> There shouldn't be any need to distinguish. If you get 0 then there's no
> defined string and you use the fallback.

Windows makes that distinction though:
 - String of length zero: TaskDialogIndirect succeeds, but no text is displayed for that parameter
 - Invalid resource: TaskDialogIndirect fails with ERROR_RESOURCE_NAME_NOT_FOUND



More information about the wine-devel mailing list