Hello,
Welcome to Microsoft Q&A!
According to the Doc: CreateDCW function
Note that the handle to the DC can only be used by a single thread at any one time.
Refer to the Doc: Get started with C++/WinRT
The call to winrt::init_apartment initializes the thread in the Windows Runtime; by default, in a multithreaded apartment.
As far as I'm concerned, you need to call winrt::init_apartment
to initializes the thread to single-threaded apartments
in the Windows Runtime.
Thank you.
Jeanine
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.