delete redundant codes
This commit is contained in:
1 parent
c1d6e901b2
commit
e3d20382d4
8 files changed
+160
-541
No files matched your search
@@ -48,7 +48,7 @@
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Window">
|
||||
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Setter Property="UseLayoutRounding" Value="True"/>
|
||||
</Style>
|
||||
@@ -56,7 +56,7 @@
|
||||
<Style x:Key="WindowWin10" TargetType="controls:Window">
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="BorderBrush" Value="#262e2f"/>
|
||||
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Setter Property="UseLayoutRounding" Value="True"/>
|
||||
<Setter Property="NonClientAreaBackground" Value="{DynamicResource RegionBrush}"/>
|
||||
@@ -178,6 +178,12 @@
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="WindowGlow" BasedOn="{StaticResource WindowWin10}" TargetType="controls:GlowWindow">
|
||||
<Setter Property="ActiveGlowColor" Value="#262e2f"/>
|
||||
<Setter Property="InactiveGlowColor" Value="{DynamicResource BorderColor}"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="controls:ImageBrowser">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="MinWidth" Value="400"/>
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Window">
|
||||
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Setter Property="UseLayoutRounding" Value="True"/>
|
||||
</Style>
|
||||
@@ -57,7 +57,7 @@
|
||||
<Style x:Key="WindowWin10" BasedOn="{x:Null}" TargetType="controls:Window">
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="BorderBrush" Value="#262e2f"/>
|
||||
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Setter Property="UseLayoutRounding" Value="True"/>
|
||||
<Setter Property="NonClientAreaBackground" Value="{DynamicResource RegionBrush}"/>
|
||||
@@ -179,8 +179,10 @@
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="WindowGlow">
|
||||
|
||||
<Style x:Key="WindowGlow" BasedOn="{StaticResource WindowWin10}" TargetType="controls:GlowWindow">
|
||||
<Setter Property="ActiveGlowColor" Value="#262e2f"/>
|
||||
<Setter Property="InactiveGlowColor" Value="{DynamicResource BorderColor}"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="controls:ImageBrowser">
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Window">
|
||||
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Setter Property="UseLayoutRounding" Value="True"/>
|
||||
</Style>
|
||||
@@ -56,7 +56,7 @@
|
||||
<Style x:Key="WindowWin10" TargetType="controls:Window">
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="BorderBrush" Value="#262e2f"/>
|
||||
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Setter Property="UseLayoutRounding" Value="True"/>
|
||||
<Setter Property="NonClientAreaBackground" Value="{DynamicResource RegionBrush}"/>
|
||||
@@ -178,6 +178,12 @@
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="WindowGlow" BasedOn="{StaticResource WindowWin10}" TargetType="controls:GlowWindow">
|
||||
<Setter Property="ActiveGlowColor" Value="#262e2f"/>
|
||||
<Setter Property="InactiveGlowColor" Value="{DynamicResource BorderColor}"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="controls:ImageBrowser">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="MinWidth" Value="400"/>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<Window x:Class="HandyControlDemo.Window.GlowWindow"
|
||||
<hc:GlowWindow x:Class="HandyControlDemo.Window.GlowWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
@@ -6,12 +6,12 @@
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
|
||||
mc:Ignorable="d"
|
||||
Background="{DynamicResource MainContentBackgroundBrush}"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Title="{x:Static langs:Lang.Title}"
|
||||
ActiveGlowColor="{DynamicResource PrimaryColor}"
|
||||
Height="450"
|
||||
Width="800"
|
||||
Icon="/HandyControlDemo;component/Resources/Img/icon.ico">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
<Border Background="{DynamicResource MainContentForegroundDrawingBrush}"/>
|
||||
</hc:GlowWindow>
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
@@ -11,17 +10,14 @@ using System.Windows.Threading;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Expression.Drawing;
|
||||
using HandyControl.Tools;
|
||||
using HandyControl.Tools.Extension;
|
||||
using HandyControl.Tools.Interop;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class GlowWindow : System.Windows.Window
|
||||
public class GlowWindow : Window
|
||||
{
|
||||
internal int DeferGlowChangesCount;
|
||||
|
||||
private IntPtr _ownerForActivate;
|
||||
|
||||
private readonly GlowEdge[] _glowEdges = new GlowEdge[4];
|
||||
|
||||
private DispatcherTimer _makeGlowVisibleTimer;
|
||||
@@ -30,12 +26,8 @@ namespace HandyControl.Controls
|
||||
|
||||
private bool _useLogicalSizeForRestore;
|
||||
|
||||
private bool _isNonClientStripVisible;
|
||||
|
||||
private bool _updatingZOrder;
|
||||
|
||||
private int _lastWindowPlacement;
|
||||
|
||||
private Rect _logicalSizeForRestore = Rect.Empty;
|
||||
|
||||
public static readonly DependencyProperty ActiveGlowColorProperty = DependencyProperty.Register(
|
||||
@@ -62,36 +54,16 @@ namespace HandyControl.Controls
|
||||
ResizeModeProperty.OverrideMetadata(typeof(GlowWindow), new FrameworkPropertyMetadata(OnResizeModeChanged));
|
||||
}
|
||||
|
||||
public void ChangeOwnerForActivate(IntPtr newOwner)
|
||||
#region internal
|
||||
|
||||
internal void EndDeferGlowChanges()
|
||||
{
|
||||
_ownerForActivate = newOwner;
|
||||
foreach (var current in LoadedGlowWindows) current.CommitChanges();
|
||||
}
|
||||
|
||||
public void ChangeOwner(IntPtr newOwner)
|
||||
{
|
||||
var _ = new WindowInteropHelper(this)
|
||||
{
|
||||
Owner = newOwner
|
||||
};
|
||||
foreach (var current in LoadedGlowWindows) current.ChangeOwner(newOwner);
|
||||
UpdateZOrderOfThisAndOwner();
|
||||
}
|
||||
#endregion
|
||||
|
||||
private static int PressedMouseButtons
|
||||
{
|
||||
get
|
||||
{
|
||||
var num = 0;
|
||||
if (InteropMethods.IsKeyPressed(1)) num |= 1;
|
||||
if (InteropMethods.IsKeyPressed(2)) num |= 2;
|
||||
if (InteropMethods.IsKeyPressed(4)) num |= 16;
|
||||
if (InteropMethods.IsKeyPressed(5)) num |= 32;
|
||||
if (InteropMethods.IsKeyPressed(6)) num |= 64;
|
||||
return num;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<GlowEdge> LoadedGlowWindows => from w in _glowEdges where w != null select w;
|
||||
#region protected
|
||||
|
||||
protected virtual bool ShouldShowGlow
|
||||
{
|
||||
@@ -103,6 +75,114 @@ namespace HandyControl.Controls
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual IntPtr HwndSourceHook(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||
{
|
||||
if (msg <= 71)
|
||||
{
|
||||
if (msg == 6)
|
||||
{
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
if (msg != 12)
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case 70:
|
||||
WmWindowPosChanging(lParam);
|
||||
return IntPtr.Zero;
|
||||
case 71:
|
||||
WmWindowPosChanged(lParam);
|
||||
return IntPtr.Zero;
|
||||
default:
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (msg <= 166)
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case 128:
|
||||
break;
|
||||
case 129:
|
||||
case 130:
|
||||
return IntPtr.Zero;
|
||||
case 134:
|
||||
handled = true;
|
||||
return WmNcActivate(hWnd, wParam);
|
||||
default:
|
||||
switch (msg)
|
||||
{
|
||||
case 164:
|
||||
case 165:
|
||||
case 166:
|
||||
handled = true;
|
||||
return IntPtr.Zero;
|
||||
default:
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case 174:
|
||||
case 175:
|
||||
handled = true;
|
||||
return IntPtr.Zero;
|
||||
default:
|
||||
if (msg != 274) return IntPtr.Zero;
|
||||
WmSysCommand(hWnd, wParam);
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handled = true;
|
||||
return CallDefWindowProcWithoutVisibleStyle(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
protected override void OnActivated(EventArgs e)
|
||||
{
|
||||
UpdateGlowActiveState();
|
||||
base.OnActivated(e);
|
||||
}
|
||||
|
||||
protected override void OnDeactivated(EventArgs e)
|
||||
{
|
||||
UpdateGlowActiveState();
|
||||
base.OnDeactivated(e);
|
||||
}
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
StopTimer();
|
||||
DestroyGlowWindows();
|
||||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
protected override void OnSourceInitialized(EventArgs e)
|
||||
{
|
||||
var hwndSource = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
|
||||
if (hwndSource != null)
|
||||
{
|
||||
hwndSource.AddHook(HwndSourceHook);
|
||||
CreateGlowWindowHandles();
|
||||
}
|
||||
|
||||
base.OnSourceInitialized(e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region private
|
||||
|
||||
private IEnumerable<GlowEdge> LoadedGlowWindows => from w in _glowEdges where w != null select w;
|
||||
|
||||
private bool IsGlowVisible
|
||||
{
|
||||
get => _isGlowVisible;
|
||||
@@ -135,10 +215,7 @@ namespace HandyControl.Controls
|
||||
customChromeWindow.UpdateGlowVisibility(false);
|
||||
}
|
||||
|
||||
private static void OnGlowColorChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
((GlowWindow)obj).UpdateGlowColors();
|
||||
}
|
||||
private static void OnGlowColorChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) => ((GlowWindow)obj).UpdateGlowColors();
|
||||
|
||||
private void UpdateGlowColors()
|
||||
{
|
||||
@@ -208,11 +285,6 @@ namespace HandyControl.Controls
|
||||
|
||||
private IDisposable DeferGlowChanges() => new ChangeScope(this);
|
||||
|
||||
internal void EndDeferGlowChanges()
|
||||
{
|
||||
foreach (var current in LoadedGlowWindows) current.CommitChanges();
|
||||
}
|
||||
|
||||
private void UpdateGlowActiveState()
|
||||
{
|
||||
using (DeferGlowChanges())
|
||||
@@ -235,13 +307,7 @@ namespace HandyControl.Controls
|
||||
}
|
||||
}
|
||||
|
||||
private void WmActivate(IntPtr wParam, IntPtr lParam)
|
||||
{
|
||||
if (_ownerForActivate != IntPtr.Zero)
|
||||
InteropMethods.SendMessage(_ownerForActivate, InteropMethods.NOTIFYOWNERACTIVATE, wParam, lParam);
|
||||
}
|
||||
|
||||
private void WmWindowPosChanging(IntPtr hwnd, IntPtr lParam)
|
||||
private void WmWindowPosChanging(IntPtr lParam)
|
||||
{
|
||||
var windowpos = (InteropValues.WINDOWPOS)Marshal.PtrToStructure(lParam, typeof(InteropValues.WINDOWPOS));
|
||||
if ((windowpos.flags & 2u) == 0u && (windowpos.flags & 1u) == 0u && windowpos.cx > 0 && windowpos.cy > 0)
|
||||
@@ -263,72 +329,6 @@ namespace HandyControl.Controls
|
||||
}
|
||||
}
|
||||
|
||||
private static InteropValues.RECT GetClientRectRelativeToWindowRect(IntPtr hWnd)
|
||||
{
|
||||
InteropMethods.GetWindowRect(hWnd, out var rect);
|
||||
InteropMethods.GetClientRect(hWnd, out var result);
|
||||
var point = new InteropValues.POINT
|
||||
{
|
||||
X = 0,
|
||||
Y = 0
|
||||
};
|
||||
InteropMethods.ClientToScreen(hWnd, ref point);
|
||||
result.Offset(point.X - rect.Left, point.Y - rect.Top);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void UpdateMaximizedClipRegion(IntPtr hWnd)
|
||||
{
|
||||
var clientRectRelativeToWindowRect = GetClientRectRelativeToWindowRect(hWnd);
|
||||
if (_isNonClientStripVisible) clientRectRelativeToWindowRect.Bottom++;
|
||||
|
||||
var hRgn = InteropMethods.CreateRectRgnIndirect(ref clientRectRelativeToWindowRect);
|
||||
InteropMethods.SetWindowRgn(hWnd, hRgn, InteropMethods.IsWindowVisible(hWnd));
|
||||
}
|
||||
|
||||
private IntPtr ComputeRoundRectRegion(int left, int top, int width, int height, int cornerRadius)
|
||||
{
|
||||
var nWidthEllipse = (int)(2 * cornerRadius * DpiHelper.LogicalToDeviceUnitsScalingFactorX);
|
||||
var nHeightEllipse = (int)(2 * cornerRadius * DpiHelper.LogicalToDeviceUnitsScalingFactorY);
|
||||
return InteropMethods.CreateRoundRectRgn(left, top, left + width + 1, top + height + 1, nWidthEllipse,
|
||||
nHeightEllipse);
|
||||
}
|
||||
|
||||
protected void SetRoundRect(IntPtr hWnd, int width, int height)
|
||||
{
|
||||
var hRgn = ComputeRoundRectRegion(0, 0, width, height, 0);
|
||||
InteropMethods.SetWindowRgn(hWnd, hRgn, InteropMethods.IsWindowVisible(hWnd));
|
||||
}
|
||||
|
||||
protected virtual bool UpdateClipRegionCore(IntPtr hWnd, int showCmd, ClipRegionChangeType changeType, Int32Rect currentBounds)
|
||||
{
|
||||
if (showCmd == 3)
|
||||
{
|
||||
UpdateMaximizedClipRegion(hWnd);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (changeType == ClipRegionChangeType.FromSize || changeType == ClipRegionChangeType.FromPropertyChange ||
|
||||
_lastWindowPlacement != showCmd)
|
||||
{
|
||||
SetRoundRect(hWnd, currentBounds.Width, currentBounds.Height);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void UpdateClipRegion(IntPtr hWnd, InteropValues.WINDOWPLACEMENT placement, ClipRegionChangeType changeType,
|
||||
InteropValues.RECT currentBounds)
|
||||
{
|
||||
UpdateClipRegionCore(hWnd, placement.showCmd, changeType, currentBounds.ToInt32Rect());
|
||||
_lastWindowPlacement = placement.showCmd;
|
||||
}
|
||||
|
||||
protected virtual void OnWindowPosChanged(IntPtr hWnd, int showCmd, Int32Rect rcNormalPosition)
|
||||
{
|
||||
}
|
||||
|
||||
private void UpdateZOrderOfOwner(IntPtr hwndOwner)
|
||||
{
|
||||
var lastOwnedWindow = IntPtr.Zero;
|
||||
@@ -366,34 +366,22 @@ namespace HandyControl.Controls
|
||||
}
|
||||
}
|
||||
|
||||
private void WmWindowPosChanged(IntPtr hWnd, IntPtr lParam)
|
||||
private void WmWindowPosChanged(IntPtr lParam)
|
||||
{
|
||||
try
|
||||
{
|
||||
var windowpos = (InteropValues.WINDOWPOS)Marshal.PtrToStructure(lParam, typeof(InteropValues.WINDOWPOS));
|
||||
var windowPlacement = InteropMethods.GetWindowPlacement(hWnd);
|
||||
var currentBounds = new InteropValues.RECT(windowpos.x, windowpos.y, windowpos.x + windowpos.cx,
|
||||
windowpos.y + windowpos.cy);
|
||||
if ((windowpos.flags & 1u) != 1u)
|
||||
{
|
||||
UpdateClipRegion(hWnd, windowPlacement, ClipRegionChangeType.FromSize, currentBounds);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((windowpos.flags & 2u) != 2u)
|
||||
UpdateClipRegion(hWnd, windowPlacement, ClipRegionChangeType.FromPosition, currentBounds);
|
||||
}
|
||||
|
||||
OnWindowPosChanged(hWnd, windowPlacement.showCmd, windowPlacement.rcNormalPosition.ToInt32Rect());
|
||||
UpdateGlowWindowPositions((windowpos.flags & 64u) == 0u);
|
||||
UpdateZOrderOfThisAndOwner();
|
||||
}
|
||||
catch (Win32Exception)
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
internal Rect GetOnScreenPosition(Rect floatRect)
|
||||
private Rect GetOnScreenPosition(Rect floatRect)
|
||||
{
|
||||
var result = floatRect;
|
||||
floatRect = floatRect.LogicalToDeviceUnits();
|
||||
@@ -422,90 +410,7 @@ namespace HandyControl.Controls
|
||||
return result;
|
||||
}
|
||||
|
||||
private InteropValues.WINDOWINFO GetWindowInfo(IntPtr hWnd)
|
||||
{
|
||||
var windowInfo = default(InteropValues.WINDOWINFO);
|
||||
windowInfo.cbSize = Marshal.SizeOf(windowInfo);
|
||||
InteropMethods.GetWindowInfo(hWnd, ref windowInfo);
|
||||
return windowInfo;
|
||||
}
|
||||
|
||||
private IntPtr WmNcCalcSize(IntPtr hWnd, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||
{
|
||||
_isNonClientStripVisible = false;
|
||||
var windowPlacement = InteropMethods.GetWindowPlacement(hWnd);
|
||||
var flag = windowPlacement.showCmd == 3;
|
||||
if (flag)
|
||||
{
|
||||
var rect = (InteropValues.RECT)Marshal.PtrToStructure(lParam, typeof(InteropValues.RECT));
|
||||
InteropMethods.DefWindowProc(hWnd, 131, wParam, lParam);
|
||||
var rect2 = (InteropValues.RECT)Marshal.PtrToStructure(lParam, typeof(InteropValues.RECT));
|
||||
var monitorinfo = MonitorInfoFromWindow(hWnd);
|
||||
if (monitorinfo.rcMonitor.Height == monitorinfo.rcWork.Height &&
|
||||
monitorinfo.rcMonitor.Width == monitorinfo.rcWork.Width)
|
||||
{
|
||||
_isNonClientStripVisible = true;
|
||||
rect2.Bottom--;
|
||||
}
|
||||
|
||||
rect2.Top = rect.Top + (int)GetWindowInfo(hWnd).cyWindowBorders;
|
||||
Marshal.StructureToPtr(rect2, lParam, true);
|
||||
}
|
||||
|
||||
handled = true;
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
private IntPtr WmNcHitTest(IntPtr hWnd, IntPtr lParam, ref bool handled)
|
||||
{
|
||||
if (PresentationSource.FromDependencyObject(this) == null) return new IntPtr(0);
|
||||
|
||||
var point = new Point(InteropMethods.GetXLParam(lParam.ToInt32()),
|
||||
InteropMethods.GetYLParam(lParam.ToInt32()));
|
||||
var point2 = PointFromScreen(point);
|
||||
DependencyObject visualHit = null;
|
||||
VisualHelper.HitTestVisibleElements(this, delegate (HitTestResult target)
|
||||
{
|
||||
visualHit = target.VisualHit;
|
||||
return HitTestResultBehavior.Stop;
|
||||
}, new PointHitTestParameters(point2));
|
||||
|
||||
var num = 0;
|
||||
while (visualHit != null)
|
||||
{
|
||||
//var nonClientArea = visualHit as INonClientArea;
|
||||
//if (nonClientArea != null)
|
||||
//{
|
||||
// num = nonClientArea.HitTest(point);
|
||||
// if (num != 0) break;
|
||||
//}
|
||||
|
||||
visualHit = visualHit.GetVisualOrLogicalParent();
|
||||
}
|
||||
|
||||
if (num == 0) num = 1;
|
||||
handled = true;
|
||||
return new IntPtr(num);
|
||||
}
|
||||
|
||||
private IntPtr WmNcActivate(IntPtr hWnd, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||
{
|
||||
handled = true;
|
||||
return InteropMethods.DefWindowProc(hWnd, 134, wParam, InteropMethods.HRGN_NONE);
|
||||
}
|
||||
|
||||
private static void RaiseNonClientMouseMessageAsClient(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam)
|
||||
{
|
||||
var point = new InteropValues.POINT
|
||||
{
|
||||
X = InteropMethods.GetXLParam(lParam.ToInt32()),
|
||||
Y = InteropMethods.GetYLParam(lParam.ToInt32())
|
||||
};
|
||||
|
||||
InteropMethods.ScreenToClient(hWnd, ref point);
|
||||
InteropMethods.SendMessage(hWnd, msg + 513 - 161, new IntPtr(PressedMouseButtons),
|
||||
InteropMethods.MakeParam(point.X, point.Y));
|
||||
}
|
||||
private IntPtr WmNcActivate(IntPtr hWnd, IntPtr wParam) => InteropMethods.DefWindowProc(hWnd, 134, wParam, InteropMethods.HRGN_NONE);
|
||||
|
||||
private bool IsAeroSnappedToMonitor(IntPtr hWnd)
|
||||
{
|
||||
@@ -515,7 +420,7 @@ namespace HandyControl.Controls
|
||||
return MathHelper.AreClose(monitorinfo.rcWork.Height, logicalRect.Height) && MathHelper.AreClose(monitorinfo.rcWork.Top, logicalRect.Top);
|
||||
}
|
||||
|
||||
private void WmSysCommand(IntPtr hWnd, IntPtr wParam, IntPtr lParam)
|
||||
private void WmSysCommand(IntPtr hWnd, IntPtr wParam)
|
||||
{
|
||||
var num = InteropMethods.GET_SC_WPARAM(wParam);
|
||||
if (num == 61456)
|
||||
@@ -537,130 +442,20 @@ namespace HandyControl.Controls
|
||||
}
|
||||
}
|
||||
|
||||
private IntPtr CallDefWindowProcWithoutVisibleStyle(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||
private IntPtr CallDefWindowProcWithoutVisibleStyle(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam)
|
||||
{
|
||||
var flag = VisualHelper.ModifyStyle(hWnd, 268435456, 0);
|
||||
var result = InteropMethods.DefWindowProc(hWnd, msg, wParam, lParam);
|
||||
if (flag) VisualHelper.ModifyStyle(hWnd, 0, 268435456);
|
||||
handled = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
protected virtual IntPtr HwndSourceHook(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||
{
|
||||
if (msg <= 71)
|
||||
{
|
||||
if (msg == 6)
|
||||
{
|
||||
WmActivate(wParam, lParam);
|
||||
goto IL_11C;
|
||||
}
|
||||
|
||||
if (msg != 12)
|
||||
switch (msg)
|
||||
{
|
||||
case 70:
|
||||
WmWindowPosChanging(hWnd, lParam);
|
||||
goto IL_11C;
|
||||
case 71:
|
||||
WmWindowPosChanged(hWnd, lParam);
|
||||
goto IL_11C;
|
||||
default:
|
||||
goto IL_11C;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (msg <= 166)
|
||||
switch (msg)
|
||||
{
|
||||
case 128:
|
||||
break;
|
||||
case 129:
|
||||
case 130:
|
||||
goto IL_11C;
|
||||
case 131:
|
||||
return WmNcCalcSize(hWnd, wParam, lParam, ref handled);
|
||||
case 132:
|
||||
return WmNcHitTest(hWnd, lParam, ref handled);
|
||||
//case 133:
|
||||
// return WmNcPaint(hWnd, wParam, lParam, ref handled);
|
||||
case 134:
|
||||
return WmNcActivate(hWnd, wParam, lParam, ref handled);
|
||||
default:
|
||||
switch (msg)
|
||||
{
|
||||
case 164:
|
||||
case 165:
|
||||
case 166:
|
||||
RaiseNonClientMouseMessageAsClient(hWnd, msg, wParam, lParam);
|
||||
handled = true;
|
||||
goto IL_11C;
|
||||
default:
|
||||
goto IL_11C;
|
||||
}
|
||||
}
|
||||
else
|
||||
switch (msg)
|
||||
{
|
||||
case 174:
|
||||
case 175:
|
||||
handled = true;
|
||||
goto IL_11C;
|
||||
default:
|
||||
if (msg != 274) goto IL_11C;
|
||||
WmSysCommand(hWnd, wParam, lParam);
|
||||
goto IL_11C;
|
||||
}
|
||||
}
|
||||
|
||||
return CallDefWindowProcWithoutVisibleStyle(hWnd, msg, wParam, lParam, ref handled);
|
||||
IL_11C:
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
private void CreateGlowWindowHandles()
|
||||
{
|
||||
for (var i = 0; i < _glowEdges.Length; i++) GetOrCreateGlowWindow(i).EnsureHandle();
|
||||
}
|
||||
|
||||
protected override void OnActivated(EventArgs e)
|
||||
{
|
||||
UpdateGlowActiveState();
|
||||
base.OnActivated(e);
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected override void OnDeactivated(EventArgs e)
|
||||
{
|
||||
UpdateGlowActiveState();
|
||||
base.OnDeactivated(e);
|
||||
}
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
StopTimer();
|
||||
DestroyGlowWindows();
|
||||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
protected override void OnSourceInitialized(EventArgs e)
|
||||
{
|
||||
var hwndSource = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
|
||||
if (hwndSource != null)
|
||||
{
|
||||
hwndSource.AddHook(HwndSourceHook);
|
||||
CreateGlowWindowHandles();
|
||||
}
|
||||
|
||||
base.OnSourceInitialized(e);
|
||||
}
|
||||
|
||||
protected enum ClipRegionChangeType
|
||||
{
|
||||
FromSize,
|
||||
FromPosition,
|
||||
FromPropertyChange,
|
||||
FromUndockSingleTab
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ namespace HandyControl.Controls
|
||||
|
||||
public static readonly DependencyProperty NonClientAreaHeightProperty = DependencyProperty.Register(
|
||||
"NonClientAreaHeight", typeof(double), typeof(Window),
|
||||
new PropertyMetadata(26.0));
|
||||
new PropertyMetadata(22.0));
|
||||
|
||||
public static readonly DependencyProperty ShowNonClientAreaProperty = DependencyProperty.Register(
|
||||
"ShowNonClientArea", typeof(bool), typeof(Window),
|
||||
@@ -80,8 +80,6 @@ namespace HandyControl.Controls
|
||||
|
||||
private Thickness _actualBorderThickness;
|
||||
|
||||
private UIElement _nonClientArea;
|
||||
|
||||
private bool _showNonClientArea = true;
|
||||
|
||||
private double _tempNonClientAreaHeight;
|
||||
@@ -92,6 +90,8 @@ namespace HandyControl.Controls
|
||||
|
||||
private ResizeMode _tempResizeMode;
|
||||
|
||||
private UIElement _nonClientArea;
|
||||
|
||||
static Window()
|
||||
{
|
||||
StyleProperty.OverrideMetadata(typeof(Window), new FrameworkPropertyMetadata(Application.Current.FindResource(ResourceToken.WindowWin10)));
|
||||
|
||||
@@ -10,17 +10,12 @@ namespace HandyControl.Tools.Interop
|
||||
{
|
||||
internal class InteropMethods
|
||||
{
|
||||
private static int vsmNotifyOwnerActivate;
|
||||
|
||||
public static readonly IntPtr HRGN_NONE = new IntPtr(-1);
|
||||
internal static readonly IntPtr HRGN_NONE = new IntPtr(-1);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
|
||||
[ResourceExposure(ResourceScope.None)]
|
||||
internal static extern int RegisterWindowMessage(string msg);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, SetLastError = true, CharSet = CharSet.Auto)]
|
||||
internal static extern int MapWindowPoints(IntPtr hWndFrom, IntPtr hWndTo, ref InteropValues.RECT lpPoints, uint cPoints);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
|
||||
internal static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, out InteropValues.TBBUTTON lpBuffer,
|
||||
int dwSize, out int lpNumberOfBytesRead);
|
||||
@@ -282,18 +277,6 @@ namespace HandyControl.Tools.Interop
|
||||
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
|
||||
internal static extern IntPtr GetDC(IntPtr ptr);
|
||||
|
||||
internal static int NOTIFYOWNERACTIVATE
|
||||
{
|
||||
get
|
||||
{
|
||||
if (vsmNotifyOwnerActivate == 0)
|
||||
{
|
||||
vsmNotifyOwnerActivate = RegisterWindowMessage("NOTIFYOWNERACTIVATE{A982313C-756C-4da9-8BD0-0C375A45784B}");
|
||||
}
|
||||
return vsmNotifyOwnerActivate;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static extern bool GetWindowPlacement(IntPtr hwnd, InteropValues.WINDOWPLACEMENT lpwndpl);
|
||||
@@ -307,23 +290,6 @@ namespace HandyControl.Tools.Interop
|
||||
}
|
||||
throw new Win32Exception(Marshal.GetLastWin32Error());
|
||||
}
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
internal static extern int GetSystemMetrics(int index);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
internal static extern int TrackPopupMenuEx(IntPtr hmenu, uint fuFlags, int x, int y, IntPtr hwnd, IntPtr lptpm);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool EnableMenuItem(IntPtr menu, uint uIDEnableItem, uint uEnable);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
internal static extern short GetKeyState(int vKey);
|
||||
|
||||
internal static bool IsKeyPressed(int vKey) => GetKeyState(vKey) < 0;
|
||||
|
||||
internal static IntPtr MakeParam(int lowWord, int highWord) => new IntPtr((lowWord & 65535) | highWord << 16);
|
||||
|
||||
internal static int GetXLParam(int lParam) => LoWord(lParam);
|
||||
|
||||
@@ -332,29 +298,14 @@ namespace HandyControl.Tools.Interop
|
||||
internal static int HiWord(int value) => (short)(value >> 16);
|
||||
|
||||
internal static int LoWord(int value) => (short)(value & 65535);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool ScreenToClient(IntPtr hWnd, ref InteropValues.POINT point);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
internal static extern IntPtr MonitorFromWindow(IntPtr handle, int flags);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool ClientToScreen(IntPtr hWnd, ref InteropValues.POINT point);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool EnumThreadWindows(uint dwThreadId, InteropValues.EnumWindowsProc lpfn, IntPtr lParam);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool PostMessage(IntPtr hWnd, int nMsg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
internal static extern IntPtr GetDCEx(IntPtr hWnd, IntPtr hrgnClip, int dwFlags);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Gdi32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool DeleteDC(IntPtr hdc);
|
||||
@@ -364,24 +315,6 @@ namespace HandyControl.Tools.Interop
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Gdi32, ExactSpelling = true, SetLastError = true)]
|
||||
internal static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Gdi32, CallingConvention = CallingConvention.StdCall, ExactSpelling = true)]
|
||||
internal static extern IntPtr CreateRoundRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int nWidthEllipse, int nHeightEllipse);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Gdi32, CallingConvention = CallingConvention.StdCall, ExactSpelling = true)]
|
||||
internal static extern IntPtr CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Gdi32, CallingConvention = CallingConvention.StdCall, ExactSpelling = true)]
|
||||
internal static extern IntPtr CreateRectRgnIndirect(ref InteropValues.RECT lprc);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Gdi32, CallingConvention = CallingConvention.StdCall, ExactSpelling = true)]
|
||||
private static extern int CombineRgn(IntPtr hrngDest, IntPtr hrgnSrc1, IntPtr hrgnSrc2, int fnCombineMode);
|
||||
|
||||
internal static int CombineRgn(IntPtr hrnDest, IntPtr hrgnSrc1, IntPtr hrgnSrc2,
|
||||
InteropValues.CombineMode combineMode) => CombineRgn(hrnDest, hrgnSrc1, hrgnSrc2, (int) combineMode);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, CallingConvention = CallingConvention.StdCall, ExactSpelling = true)]
|
||||
internal static extern int SetWindowRgn(IntPtr hWnd, IntPtr hRgn, [MarshalAs(UnmanagedType.Bool)] bool redraw);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
internal static extern IntPtr SendMessage(IntPtr hWnd, int nMsg, IntPtr wParam, IntPtr lParam);
|
||||
@@ -391,10 +324,6 @@ namespace HandyControl.Tools.Interop
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
internal static extern IntPtr GetWindow(IntPtr hwnd, int nCmd);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool GetWindowInfo(IntPtr hwnd, ref InteropValues.WINDOWINFO pwi);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
@@ -427,10 +356,6 @@ namespace HandyControl.Tools.Interop
|
||||
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
|
||||
|
||||
internal static int GetWindowLong(IntPtr hWnd, InteropValues.GWL nIndex) => GetWindowLong(hWnd, (int)nIndex);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool GetClientRect(IntPtr hwnd, out InteropValues.RECT lpRect);
|
||||
|
||||
internal static IntPtr SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong)
|
||||
{
|
||||
@@ -473,9 +398,6 @@ namespace HandyControl.Tools.Interop
|
||||
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
internal static extern IntPtr CreateWindowEx(int dwExStyle, IntPtr classAtom, string lpWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lpParam);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.Gdi32)]
|
||||
internal static extern IntPtr CreateSolidBrush(int colorref);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool DestroyWindow(IntPtr hwnd);
|
||||
@@ -490,11 +412,7 @@ namespace HandyControl.Tools.Interop
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
internal static extern bool RedrawWindow(IntPtr hWnd, IntPtr lprcUpdate, IntPtr hrgnUpdate, InteropValues.RedrawWindowFlags flags);
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool FillRect(IntPtr hDC, ref InteropValues.RECT rect, IntPtr hbrush);
|
||||
|
||||
|
||||
[DllImport(InteropValues.ExternDll.User32)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool EnumDisplayMonitors(IntPtr hdc, IntPtr lprcClip, InteropValues.EnumMonitorsDelegate lpfnEnum, IntPtr dwData);
|
||||
|
||||
@@ -26,12 +26,7 @@ namespace HandyControl.Tools.Interop
|
||||
|
||||
internal delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
|
||||
|
||||
internal delegate IntPtr SubclassProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, UIntPtr id, IntPtr refData);
|
||||
|
||||
internal delegate IntPtr WindowsHookProc(CbtHookAction code, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
internal const int
|
||||
WS_CHILD = 0x40000000,
|
||||
BITSPIXEL = 12,
|
||||
PLANES = 14,
|
||||
BI_RGB = 0,
|
||||
@@ -40,9 +35,6 @@ namespace HandyControl.Tools.Interop
|
||||
NIF_ICON = 0x00000002,
|
||||
NIF_TIP = 0x00000004,
|
||||
NIF_INFO = 0x00000010,
|
||||
NIN_BALLOONSHOW = WM_USER + 2,
|
||||
NIN_BALLOONHIDE = WM_USER + 3,
|
||||
NIN_BALLOONTIMEOUT = WM_USER + 4,
|
||||
NIM_ADD = 0x00000000,
|
||||
NIM_MODIFY = 0x00000001,
|
||||
NIM_DELETE = 0x00000002,
|
||||
@@ -50,22 +42,15 @@ namespace HandyControl.Tools.Interop
|
||||
NIIF_INFO = 0x00000001,
|
||||
NIIF_WARNING = 0x00000002,
|
||||
NIIF_ERROR = 0x00000003,
|
||||
NIIF_LARGE_ICON = 0x00000020,
|
||||
WM_KEYDOWN = 0x0100,
|
||||
WM_KEYUP = 0x0101,
|
||||
WM_SYSKEYDOWN = 0x0104,
|
||||
WM_SYSKEYUP = 0x0105,
|
||||
WM_SYSCOMMAND = 0x112,
|
||||
WM_MOUSEMOVE = 0x0200,
|
||||
WM_LBUTTONDOWN = 0x0201,
|
||||
WM_LBUTTONUP = 0x0202,
|
||||
WM_LBUTTONDBLCLK = 0x0203,
|
||||
WM_RBUTTONDOWN = 0x0204,
|
||||
WM_RBUTTONUP = 0x0205,
|
||||
WM_RBUTTONDBLCLK = 0x0206,
|
||||
WM_MBUTTONDOWN = 0x0207,
|
||||
WM_MBUTTONUP = 0x0208,
|
||||
WM_MBUTTONDBLCLK = 0x0209,
|
||||
WM_CLIPBOARDUPDATE = 0x031D,
|
||||
WM_USER = 0x0400,
|
||||
MF_BYPOSITION = 0x400,
|
||||
@@ -73,22 +58,10 @@ namespace HandyControl.Tools.Interop
|
||||
TB_GETBUTTON = WM_USER + 23,
|
||||
TB_BUTTONCOUNT = WM_USER + 24,
|
||||
TB_GETITEMRECT = WM_USER + 29,
|
||||
STANDARD_RIGHTS_REQUIRED = 0x000F0000,
|
||||
SYNCHRONIZE = 0x00100000,
|
||||
PROCESS_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFF,
|
||||
MEM_COMMIT = 0x1000,
|
||||
MEM_RELEASE = 0x8000,
|
||||
PAGE_READWRITE = 0x04,
|
||||
TBSTATE_HIDDEN = 0x08,
|
||||
VERTRES = 10,
|
||||
HORZRES = 8,
|
||||
DESKTOPVERTRES = 117,
|
||||
DESKTOPHORZRES = 118,
|
||||
LOGPIXELSX = 88,
|
||||
LOGPIXELSY = 90,
|
||||
CXFRAME = 32,
|
||||
CXSIZEFRAME = CXFRAME,
|
||||
SW_HIDE = 0;
|
||||
LOGPIXELSY = 90;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||
internal class NOTIFYICONDATA
|
||||
@@ -220,14 +193,6 @@ namespace HandyControl.Tools.Interop
|
||||
public int Right;
|
||||
public int Bottom;
|
||||
|
||||
public RECT(int left, int top, int right, int bottom)
|
||||
{
|
||||
Left = left;
|
||||
Top = top;
|
||||
Right = right;
|
||||
Bottom = bottom;
|
||||
}
|
||||
|
||||
public RECT(Rect rect)
|
||||
{
|
||||
Left = (int)rect.Left;
|
||||
@@ -250,16 +215,6 @@ namespace HandyControl.Tools.Interop
|
||||
get => Right - Left;
|
||||
set => Right = Left + value;
|
||||
}
|
||||
|
||||
public void Offset(int dx, int dy)
|
||||
{
|
||||
Left += dx;
|
||||
Right += dx;
|
||||
Top += dy;
|
||||
Bottom += dy;
|
||||
}
|
||||
|
||||
public Int32Rect ToInt32Rect() => new Int32Rect(Left, Top, Width, Height);
|
||||
}
|
||||
|
||||
internal struct BLENDFUNCTION
|
||||
@@ -269,11 +224,13 @@ namespace HandyControl.Tools.Interop
|
||||
public byte SourceConstantAlpha;
|
||||
public byte AlphaFormat;
|
||||
}
|
||||
|
||||
internal enum GWL
|
||||
{
|
||||
STYLE = -16,
|
||||
EXSTYLE = -20
|
||||
}
|
||||
|
||||
internal enum GWLP
|
||||
{
|
||||
WNDPROC = -4,
|
||||
@@ -282,26 +239,6 @@ namespace HandyControl.Tools.Interop
|
||||
USERDATA = -21,
|
||||
ID = -12
|
||||
}
|
||||
internal enum CombineMode
|
||||
{
|
||||
RGN_AND = 1,
|
||||
RGN_OR,
|
||||
RGN_XOR,
|
||||
RGN_DIFF,
|
||||
RGN_COPY,
|
||||
RGN_MIN = 1,
|
||||
RGN_MAX = 5
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class BITMAPFILEHEADER
|
||||
{
|
||||
public ushort bfType;
|
||||
public uint bfSize;
|
||||
public ushort bfReserved1;
|
||||
public ushort bfReserved2;
|
||||
public uint bfOffBits;
|
||||
}
|
||||
|
||||
internal struct BITMAPINFOHEADER
|
||||
{
|
||||
@@ -318,23 +255,6 @@ namespace HandyControl.Tools.Interop
|
||||
internal uint biClrImportant;
|
||||
}
|
||||
|
||||
internal struct PictDescBitmap
|
||||
{
|
||||
internal int cbSizeOfStruct;
|
||||
internal int pictureType;
|
||||
internal IntPtr hBitmap;
|
||||
internal IntPtr hPalette;
|
||||
internal int unused;
|
||||
internal static PictDescBitmap Default =>
|
||||
new PictDescBitmap
|
||||
{
|
||||
cbSizeOfStruct = 20,
|
||||
pictureType = 1,
|
||||
hBitmap = IntPtr.Zero,
|
||||
hPalette = IntPtr.Zero
|
||||
};
|
||||
}
|
||||
|
||||
[Flags]
|
||||
internal enum RedrawWindowFlags : uint
|
||||
{
|
||||
@@ -352,20 +272,6 @@ namespace HandyControl.Tools.Interop
|
||||
NoFrame = 2048u
|
||||
}
|
||||
|
||||
internal enum CbtHookAction
|
||||
{
|
||||
HCBT_MOVESIZE,
|
||||
HCBT_MINMAX,
|
||||
HCBT_QS,
|
||||
HCBT_CREATEWND,
|
||||
HCBT_DESTROYWND,
|
||||
HCBT_ACTIVATE,
|
||||
HCBT_CLICKSKIPPED,
|
||||
HCBT_KEYSKIPPED,
|
||||
HCBT_SYSCOMMAND,
|
||||
HCBT_SETFOCUS
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class WINDOWPOS
|
||||
{
|
||||
@@ -389,20 +295,6 @@ namespace HandyControl.Tools.Interop
|
||||
public RECT rcNormalPosition;
|
||||
}
|
||||
|
||||
internal struct WINDOWINFO
|
||||
{
|
||||
public int cbSize;
|
||||
public RECT rcWindow;
|
||||
public RECT rcClient;
|
||||
public int dwStyle;
|
||||
public int dwExStyle;
|
||||
public uint dwWindowStatus;
|
||||
public uint cxWindowBorders;
|
||||
public uint cyWindowBorders;
|
||||
public ushort atomWindowType;
|
||||
public ushort wCreatorVersion;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
internal struct SIZE
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user