Skip to content

Commit

Permalink
Improve CoreWindow host window implementation. (Thanks to Yifei Gao.)
Browse files Browse the repository at this point in the history
  • Loading branch information
MouriNaruto committed Apr 13, 2024
1 parent c93a2be commit ae87c4e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
38 changes: 38 additions & 0 deletions Mile.Xaml.Managed/CoreWindowHost.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* PROJECT: Mouri Internal Library Essentials
* FILE: CoreWindowHost.cs
* PURPOSE: Definition for Mile.Xaml.CoreWindowHost
*
* LICENSE: The MIT License
*
* MAINTAINER: MouriNaruto (Kenji.Mouri@outlook.com)
*/

using System.Windows.Forms;

namespace Mile.Xaml
{
internal class CoreWindowHost : Form
{
private const int WS_EX_TRANSPARENT = 0x00000020;
private const int WS_EX_LAYERED = 0x00080000;

public CoreWindowHost()
{
Controls.Add(new WindowsXamlHost());
Show();
Hide();
}

protected override CreateParams CreateParams
{
get
{
CreateParams CreateParameters = base.CreateParams;
CreateParameters.ExStyle = WS_EX_TRANSPARENT | WS_EX_LAYERED;
CreateParameters.Style = 0;
return CreateParameters;
}
}
}
}
5 changes: 1 addition & 4 deletions Mile.Xaml.Managed/XamlApplicationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ public static void ThreadInitialize(
// better workaround.
if (CoreWindowHostWindow == null)
{
CoreWindowHostWindow = new System.Windows.Forms.Form();
CoreWindowHostWindow.Controls.Add(new WindowsXamlHost());
CoreWindowHostWindow.Show();
CoreWindowHostWindow.Hide();
CoreWindowHostWindow = new CoreWindowHost();
}
}

Expand Down

0 comments on commit ae87c4e

Please sign in to comment.