Skip to content

Make DirectCompositionLayeredChildWindow compatible with Unicode build - #335

Open
Ratin Gao (RatinCN) wants to merge 1 commit into
microsoft:mainfrom
RatinCN:Fix_DirectCompositionLayeredChildWindow_Unicode_Build
Open

Make DirectCompositionLayeredChildWindow compatible with Unicode build#335
Ratin Gao (RatinCN) wants to merge 1 commit into
microsoft:mainfrom
RatinCN:Fix_DirectCompositionLayeredChildWindow_Unicode_Build

Conversation

@RatinCN

@RatinCN Ratin Gao (RatinCN) commented Feb 29, 2024

Copy link
Copy Markdown

The sample "DirectCompositionLayeredChildWindow" can compatible with Unicode build just make some very small changes.

And this PR also fix empty error message displayed due to

// Show error messages.
void CApplication::ShowErrorMessage(PCWSTR format, HRESULT hrErr)
{
    WCHAR msg[MAX_PATH];
    HRESULT hr = StringCbPrintf((STRSAFE_LPSTR)msg, sizeof(msg), (STRSAFE_LPCSTR)(L"%s (hr=0x%08X)"), format, hrErr);

    if (SUCCEEDED(hr))
    {
        MessageBox(NULL, (LPCSTR)msg, NULL, MB_ICONERROR);
    }
}

Where use %s to format a PCWSTR string even if in ANSI build.

Before:
Before

After:
After

@zhuman Zachary Northrup (zhuman) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would typically just update projects to use L"" strings and only support Unicode but this is fine too :-)

@RatinCN

Copy link
Copy Markdown
Author

Chris Guzak (@ChrisGuzak) Okay to move on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants