I want a Winui3 window, to host a Win32 control, I tried the following:
App.xaml.cs:
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
m_window = new MainWindow();
var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(m_window);
var ctrl = CreateWindow("EDIT", "Edit", WindowStyles.WS_CHILD | WindowStyles.WS_VISIBLE, 100, 100, 300, 50, hwnd, (IntPtr)0, (IntPtr)0, (IntPtr)0);
m_window.Activate();
}
Unfortunately, the control did not show up directly, It was only visible if you resize the window really fast. I think that's because the control is created behind the XAML. I tried to fix this, by setting the WindowStyle to TopMost, but it didn't work either.
SetWindowPos(ctrl, (IntPtr)(-1), 0, 0, 0, 0, SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE);
Is there a workaround, or did I forget something?
The documentation, to access Win32 apis: https://learn.microsoft.com/en-us/windows/apps/winui/winui3/desktop-winui3-app-with-basic-interop