I am interested in porting some Win32 XAML Islands code to WinUI 3 for a future release - but I have one major question that I can't seem to find an answer to anywhere: is there a way to host WinUI 3 in a custom wWinMain function and with a custom message loop?
I am asking this because currently:
- I am using some Win32 features and third party components that require
PreTranslateMessage to be inserted in the message loop
- I need some custom initialization in that happens before anything from WinUI in
wWinMain
- I use APIs like
WriteFileEx, which require to use MsgWaitForMultipleObjectsEx instead of the GetMessage loop.
Sure, I could just wait for WinUI 3's XAML islands and port all my existing code to that, but that seems like far away still, and I want to make use of WinUI's Window class to be able to remove most of my custom XAML island hosting code, since Window covers most of my use cases.
From what I understand, I can just disable the XAML generated main and use my own wWinMain for the first part, but the XAML generated main calls into Application.Start, which blocks until the app exits: this is undesired, and I can't find a non-blocking alternative.
Another side question: can we mix normal WinUI 3 and WinUI 3 XAML Islands in the same app?
I am interested in porting some Win32 XAML Islands code to WinUI 3 for a future release - but I have one major question that I can't seem to find an answer to anywhere: is there a way to host WinUI 3 in a custom
wWinMainfunction and with a custom message loop?I am asking this because currently:
PreTranslateMessageto be inserted in the message loopwWinMainWriteFileEx, which require to useMsgWaitForMultipleObjectsExinstead of theGetMessageloop.Sure, I could just wait for WinUI 3's XAML islands and port all my existing code to that, but that seems like far away still, and I want to make use of WinUI's
Windowclass to be able to remove most of my custom XAML island hosting code, sinceWindowcovers most of my use cases.From what I understand, I can just disable the XAML generated main and use my own
wWinMainfor the first part, but the XAML generated main calls intoApplication.Start, which blocks until the app exits: this is undesired, and I can't find a non-blocking alternative.Another side question: can we mix normal WinUI 3 and WinUI 3 XAML Islands in the same app?