DWM API moved into a folder
This commit is contained in:
20
Eve-O-Preview/DwmAPI/DWM_BLURBEHIND.cs
Normal file
20
Eve-O-Preview/DwmAPI/DWM_BLURBEHIND.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace EveOPreview
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
class DWM_BLURBEHIND
|
||||
{
|
||||
public uint dwFlags;
|
||||
[MarshalAs(UnmanagedType.Bool)]
|
||||
public bool fEnable;
|
||||
public IntPtr hRegionBlur;
|
||||
[MarshalAs(UnmanagedType.Bool)]
|
||||
public bool fTransitionOnMaximized;
|
||||
|
||||
public const uint DWM_BB_ENABLE = 0x00000001;
|
||||
public const uint DWM_BB_BLURREGION = 0x00000002;
|
||||
public const uint DWM_BB_TRANSITIONONMAXIMIZED = 0x00000004;
|
||||
}
|
||||
}
|
23
Eve-O-Preview/DwmAPI/DWM_THUMBNAIL_PROPERTIES.cs
Normal file
23
Eve-O-Preview/DwmAPI/DWM_THUMBNAIL_PROPERTIES.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace EveOPreview
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class DWM_THUMBNAIL_PROPERTIES
|
||||
{
|
||||
public uint dwFlags;
|
||||
public RECT rcDestination;
|
||||
public RECT rcSource;
|
||||
public byte opacity;
|
||||
[MarshalAs(UnmanagedType.Bool)]
|
||||
public bool fVisible;
|
||||
[MarshalAs(UnmanagedType.Bool)]
|
||||
public bool fSourceClientAreaOnly;
|
||||
|
||||
public const uint DWM_TNP_RECTDESTINATION = 0x00000001;
|
||||
public const uint DWM_TNP_RECTSOURCE = 0x00000002;
|
||||
public const uint DWM_TNP_OPACITY = 0x00000004;
|
||||
public const uint DWM_TNP_VISIBLE = 0x00000008;
|
||||
public const uint DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010;
|
||||
}
|
||||
}
|
@@ -1,14 +1,12 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
|
||||
namespace EveOPreview
|
||||
{
|
||||
// Desktop Windows Manager APIs
|
||||
internal class DwmApi
|
||||
static class DwmApiNativeMethods
|
||||
{
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr GetForegroundWindow();
|
||||
|
||||
@@ -43,65 +41,8 @@ namespace EveOPreview
|
||||
|
||||
[DllImport("dwmapi.dll", PreserveSig = false)]
|
||||
public static extern void DwmQueryThumbnailSourceSize(IntPtr hThumbnail, out Size size);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class DWM_THUMBNAIL_PROPERTIES
|
||||
{
|
||||
public uint dwFlags;
|
||||
public RECT rcDestination;
|
||||
public RECT rcSource;
|
||||
public byte opacity;
|
||||
[MarshalAs(UnmanagedType.Bool)]
|
||||
public bool fVisible;
|
||||
[MarshalAs(UnmanagedType.Bool)]
|
||||
public bool fSourceClientAreaOnly;
|
||||
|
||||
public const uint DWM_TNP_RECTDESTINATION = 0x00000001;
|
||||
public const uint DWM_TNP_RECTSOURCE = 0x00000002;
|
||||
public const uint DWM_TNP_OPACITY = 0x00000004;
|
||||
public const uint DWM_TNP_VISIBLE = 0x00000008;
|
||||
public const uint DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class MARGINS
|
||||
{
|
||||
public int cxLeftWidth, cxRightWidth, cyTopHeight, cyBottomHeight;
|
||||
|
||||
public MARGINS(int left, int top, int right, int bottom)
|
||||
{
|
||||
cxLeftWidth = left; cyTopHeight = top;
|
||||
cxRightWidth = right; cyBottomHeight = bottom;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class DWM_BLURBEHIND
|
||||
{
|
||||
public uint dwFlags;
|
||||
[MarshalAs(UnmanagedType.Bool)]
|
||||
public bool fEnable;
|
||||
public IntPtr hRegionBlur;
|
||||
[MarshalAs(UnmanagedType.Bool)]
|
||||
public bool fTransitionOnMaximized;
|
||||
|
||||
public const uint DWM_BB_ENABLE = 0x00000001;
|
||||
public const uint DWM_BB_BLURREGION = 0x00000002;
|
||||
public const uint DWM_BB_TRANSITIONONMAXIMIZED = 0x00000004;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RECT
|
||||
{
|
||||
public int left, top, right, bottom;
|
||||
|
||||
public RECT(int left, int top, int right, int bottom)
|
||||
{
|
||||
this.left = left; this.top = top; this.right = right; this.bottom = bottom;
|
||||
}
|
||||
}
|
||||
|
||||
public const int SW_SHOWNORMAL = 1;
|
||||
public const int SW_SHOWNORMAL = 1;
|
||||
public const int SW_SHOWMINIMIZED = 2;
|
||||
public const int SW_SHOWMAXIMIZED = 3;
|
||||
|
||||
@@ -174,6 +115,5 @@ namespace EveOPreview
|
||||
public const UInt32 WS_EX_LAYOUTRTL = 0x00400000; // Right to left mirroring
|
||||
public const UInt32 WS_EX_COMPOSITED = 0x02000000;
|
||||
public const UInt32 WS_EX_NOACTIVATE = 0x08000000;
|
||||
|
||||
}
|
||||
}
|
21
Eve-O-Preview/DwmAPI/MARGINS.cs
Normal file
21
Eve-O-Preview/DwmAPI/MARGINS.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace EveOPreview
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
class MARGINS
|
||||
{
|
||||
public int cxLeftWidth;
|
||||
public int cxRightWidth;
|
||||
public int cyTopHeight;
|
||||
public int cyBottomHeight;
|
||||
|
||||
public MARGINS(int left, int top, int right, int bottom)
|
||||
{
|
||||
cxLeftWidth = left;
|
||||
cyTopHeight = top;
|
||||
cxRightWidth = right;
|
||||
cyBottomHeight = bottom;
|
||||
}
|
||||
}
|
||||
}
|
21
Eve-O-Preview/DwmAPI/RECT.cs
Normal file
21
Eve-O-Preview/DwmAPI/RECT.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace EveOPreview
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
struct RECT
|
||||
{
|
||||
public int left;
|
||||
public int top;
|
||||
public int right;
|
||||
public int bottom;
|
||||
|
||||
public RECT(int left, int top, int right, int bottom)
|
||||
{
|
||||
this.left = left;
|
||||
this.top = top;
|
||||
this.right = right;
|
||||
this.bottom = bottom;
|
||||
}
|
||||
}
|
||||
}
|
@@ -96,6 +96,10 @@
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DwmAPI\DWM_BLURBEHIND.cs" />
|
||||
<Compile Include="DwmAPI\DWM_THUMBNAIL_PROPERTIES.cs" />
|
||||
<Compile Include="DwmAPI\MARGINS.cs" />
|
||||
<Compile Include="DwmAPI\RECT.cs" />
|
||||
<Compile Include="Hotkeys\Hotkey.cs" />
|
||||
<Compile Include="Hotkeys\HotkeyNativeMethods.cs" />
|
||||
<Compile Include="PreviewHandler.cs">
|
||||
@@ -153,7 +157,7 @@
|
||||
<Compile Include="Preview.Designer.cs">
|
||||
<DependentUpon>Preview.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Win32api.cs" />
|
||||
<Compile Include="DwmAPI\DwmApiNativeMethods.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
|
||||
|
@@ -17,7 +17,7 @@ namespace EveOPreview
|
||||
|
||||
private IntPtr m_hThumbnail;
|
||||
public IntPtr sourceWindow;
|
||||
private DwmApi.DWM_THUMBNAIL_PROPERTIES m_ThumbnailProperties;
|
||||
private DWM_THUMBNAIL_PROPERTIES m_ThumbnailProperties;
|
||||
private bool has_been_set_up = false;
|
||||
private bool thumbnail_has_been_set_up = false;
|
||||
private PreviewToyHandler spawner;
|
||||
@@ -231,14 +231,14 @@ namespace EveOPreview
|
||||
{
|
||||
if (has_been_set_up)
|
||||
{
|
||||
if (DwmApi.DwmIsCompositionEnabled())
|
||||
if (DwmApiNativeMethods.DwmIsCompositionEnabled())
|
||||
{
|
||||
if (thumbnail_has_been_set_up == false)
|
||||
{
|
||||
this.SetUpThumbnail();
|
||||
}
|
||||
m_ThumbnailProperties.rcDestination = new DwmApi.RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom);
|
||||
DwmApi.DwmUpdateThumbnailProperties(m_hThumbnail, m_ThumbnailProperties);
|
||||
m_ThumbnailProperties.rcDestination = new RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom);
|
||||
DwmApiNativeMethods.DwmUpdateThumbnailProperties(m_hThumbnail, m_ThumbnailProperties);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -284,21 +284,21 @@ namespace EveOPreview
|
||||
|
||||
private void SetUpThumbnail()
|
||||
{
|
||||
if (DwmApi.DwmIsCompositionEnabled() && !thumbnail_has_been_set_up)
|
||||
if (DwmApiNativeMethods.DwmIsCompositionEnabled() && !thumbnail_has_been_set_up)
|
||||
{
|
||||
m_hThumbnail = DwmApi.DwmRegisterThumbnail(this.Handle, sourceWindow);
|
||||
m_hThumbnail = DwmApiNativeMethods.DwmRegisterThumbnail(this.Handle, sourceWindow);
|
||||
|
||||
m_ThumbnailProperties = new DwmApi.DWM_THUMBNAIL_PROPERTIES();
|
||||
m_ThumbnailProperties.dwFlags = DwmApi.DWM_THUMBNAIL_PROPERTIES.DWM_TNP_VISIBLE
|
||||
+ DwmApi.DWM_THUMBNAIL_PROPERTIES.DWM_TNP_OPACITY
|
||||
+ DwmApi.DWM_THUMBNAIL_PROPERTIES.DWM_TNP_RECTDESTINATION
|
||||
+ DwmApi.DWM_THUMBNAIL_PROPERTIES.DWM_TNP_SOURCECLIENTAREAONLY;
|
||||
m_ThumbnailProperties = new DWM_THUMBNAIL_PROPERTIES();
|
||||
m_ThumbnailProperties.dwFlags = DWM_THUMBNAIL_PROPERTIES.DWM_TNP_VISIBLE
|
||||
+ DWM_THUMBNAIL_PROPERTIES.DWM_TNP_OPACITY
|
||||
+ DWM_THUMBNAIL_PROPERTIES.DWM_TNP_RECTDESTINATION
|
||||
+ DWM_THUMBNAIL_PROPERTIES.DWM_TNP_SOURCECLIENTAREAONLY;
|
||||
m_ThumbnailProperties.opacity = 255;
|
||||
m_ThumbnailProperties.fVisible = true;
|
||||
m_ThumbnailProperties.fSourceClientAreaOnly = true;
|
||||
m_ThumbnailProperties.rcDestination = new DwmApi.RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom);
|
||||
m_ThumbnailProperties.rcDestination = new RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom);
|
||||
|
||||
DwmApi.DwmUpdateThumbnailProperties(m_hThumbnail, m_ThumbnailProperties);
|
||||
DwmApiNativeMethods.DwmUpdateThumbnailProperties(m_hThumbnail, m_ThumbnailProperties);
|
||||
|
||||
thumbnail_has_been_set_up = true;
|
||||
}
|
||||
@@ -311,15 +311,15 @@ namespace EveOPreview
|
||||
|
||||
public void bring_client_to_foreground()
|
||||
{
|
||||
DwmApi.SetForegroundWindow(sourceWindow);
|
||||
int style = DwmApi.GetWindowLong(sourceWindow, DwmApi.GWL_STYLE);
|
||||
if ((style & DwmApi.WS_MAXIMIZE) == DwmApi.WS_MAXIMIZE)
|
||||
DwmApiNativeMethods.SetForegroundWindow(sourceWindow);
|
||||
int style = DwmApiNativeMethods.GetWindowLong(sourceWindow, DwmApiNativeMethods.GWL_STYLE);
|
||||
if ((style & DwmApiNativeMethods.WS_MAXIMIZE) == DwmApiNativeMethods.WS_MAXIMIZE)
|
||||
{
|
||||
//It's maximized
|
||||
}
|
||||
else if ((style & DwmApi.WS_MINIMIZE) == DwmApi.WS_MINIMIZE)
|
||||
else if ((style & DwmApiNativeMethods.WS_MINIMIZE) == DwmApiNativeMethods.WS_MINIMIZE)
|
||||
{
|
||||
DwmApi.ShowWindowAsync(sourceWindow, DwmApi.SW_SHOWNORMAL);
|
||||
DwmApiNativeMethods.ShowWindowAsync(sourceWindow, DwmApiNativeMethods.SW_SHOWNORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -224,7 +224,7 @@ namespace EveOPreview
|
||||
refresh_client_window_locations(process);
|
||||
}
|
||||
|
||||
if (process.MainWindowHandle == DwmApi.GetForegroundWindow())
|
||||
if (process.MainWindowHandle == DwmApiNativeMethods.GetForegroundWindow())
|
||||
{
|
||||
active_client_handle = process.MainWindowHandle;
|
||||
active_client_title = process.MainWindowTitle;
|
||||
@@ -512,7 +512,7 @@ namespace EveOPreview
|
||||
private void refresh_thumbnails()
|
||||
{
|
||||
|
||||
IntPtr active_window = DwmApi.GetForegroundWindow();
|
||||
IntPtr active_window = DwmApiNativeMethods.GetForegroundWindow();
|
||||
|
||||
// hide, show, resize and move
|
||||
foreach (KeyValuePair<IntPtr, Preview> entry in previews)
|
||||
@@ -547,7 +547,7 @@ namespace EveOPreview
|
||||
}
|
||||
}
|
||||
|
||||
DwmApi.DwmIsCompositionEnabled();
|
||||
DwmApiNativeMethods.DwmIsCompositionEnabled();
|
||||
}
|
||||
|
||||
|
||||
@@ -566,7 +566,7 @@ namespace EveOPreview
|
||||
|
||||
foreach (KeyValuePair<IntPtr, Preview> entry in previews)
|
||||
{
|
||||
if (entry.Value.Handle != DwmApi.GetForegroundWindow())
|
||||
if (entry.Value.Handle != DwmApiNativeMethods.GetForegroundWindow())
|
||||
{
|
||||
entry.Value.set_render_area_size(sync_size);
|
||||
}
|
||||
@@ -607,7 +607,7 @@ namespace EveOPreview
|
||||
refresh_thumbnails();
|
||||
if (ignoring_size_sync.ElapsedMilliseconds > 500) { ignoring_size_sync.Stop(); };
|
||||
|
||||
if (DwmApi.DwmIsCompositionEnabled())
|
||||
if (DwmApiNativeMethods.DwmIsCompositionEnabled())
|
||||
{
|
||||
aero_status_label.Text = "AERO is ON";
|
||||
aero_status_label.ForeColor = Color.Black;
|
||||
|
Reference in New Issue
Block a user