Skip to content

Commit

Permalink
Just new GetWindowHandle helper
Browse files Browse the repository at this point in the history
  • Loading branch information
dotMorten committed Jul 27, 2021
1 parent 3cd413a commit a300046
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
12 changes: 2 additions & 10 deletions src/WinUIEx/WindowExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ namespace WinUIEx
/// </summary>
public static class WindowExtensions
{
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("EECDBF0E-BAE9-4CB6-A68E-9598E1CB57BB")]
internal interface IWindowNative
{
IntPtr WindowHandle { get; }
}

/// <summary>Returns the dots per inch (dpi) value for the associated window.</summary>
/// <param name = "window">The window you want to get information about.</param>
/// <returns>The DPI for the window which depends on the <a href = "/windows/desktop/api/windef/ne-windef-dpi_awareness">DPI_AWARENESS</a> of the window. See the Remarks for more information. An invalid <i>hwnd</i> value will result in a return value of 0.</returns>
Expand Down Expand Up @@ -79,8 +71,8 @@ public static void SetWindowSize(this Microsoft.UI.Xaml.Window window, double wi
/// </summary>
/// <param name="window">The window to return the handle for</param>
/// <returns>HWND handle</returns>
public static IntPtr GetWindowHandle(this Microsoft.UI.Xaml.Window window)
=> window is null ? throw new ArgumentNullException(nameof(window)) : window.As<IWindowNative>().WindowHandle;
public static IntPtr GetWindowHandle(this Microsoft.UI.Xaml.Window window)
=> window is null ? throw new ArgumentNullException(nameof(window)) : WinRT.Interop.WindowNative.GetWindowHandle(window);

/// <summary>
/// Activates the window and displays it in its current size and position.
Expand Down
4 changes: 2 additions & 2 deletions src/WinUIExSample (Package)/WinUIExSample (Package).wapproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ProjectReunion" Version="[0.8.0]">
<PackageReference Include="Microsoft.ProjectReunion" Version="[0.8.1]">
<IncludeAssets>build</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.ProjectReunion.WinUI" Version="[0.8.0]">
<PackageReference Include="Microsoft.ProjectReunion.WinUI" Version="[0.8.1]">
<IncludeAssets>build</IncludeAssets>
</PackageReference>
</ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/WinUIExSample/WinUIExSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.ProjectReunion" Version="0.8.0" />
<PackageReference Include="Microsoft.ProjectReunion.Foundation" Version="0.8.0" />
<PackageReference Include="Microsoft.ProjectReunion.WinUI" Version="0.8.0" />
<PackageReference Include="Microsoft.ProjectReunion" Version="0.8.1" />
<PackageReference Include="Microsoft.ProjectReunion.Foundation" Version="0.8.1" />
<PackageReference Include="Microsoft.ProjectReunion.WinUI" Version="0.8.1" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>

Expand Down

0 comments on commit a300046

Please sign in to comment.