Closed wayneforrest closed 6 months ago
In a desktop app, before using an instance of this class in a way that displays UI, you'll need to associate the object with its owner's window handle. For more info, and code examples, see Display WinRT UI objects that depend on CoreWindow.
https://learn.microsoft.com/en-us/uwp/api/windows.services.store.storecontext?view=winrt-22621
Hi @sylveon , I had a look at the examples you referred to and it appears it's for WinUI 3, and not for MFC.
Do you perhaps know of an MFC example I can refer to?
The example is pretty much the same without WinUI 3, you associate the StoreContext
object to a window by querying it for IInitializeWithWindow
(using storeContext.as<IInitializeWithWindow>()
), then call Initialize
on the returned object, passing in your HWND.
I don't know why they said this was for an example for WinUI 3 when it applies to all Win32 apps.
Also, your transition to a background thread isn't really needed here.
Version
C++/WinRT v2.0.220110.5
Summary
I am unable to use WinRT with MFC - "this function must be called from a UI thread"
Reproducible example
Expected behavior
No response
Actual behavior
No response
Additional comments
This is not an actual bug, a simple example of MFC and WinRT would be helpful for me to use WinRT.
Thank you.