Skip to content

Commit

Permalink
on max set ResizeBorderThickness to 0
Browse files Browse the repository at this point in the history
for dragging maximized window from top
  • Loading branch information
punker76 committed Mar 14, 2014
1 parent b096c7b commit 96d9a7b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions MahApps.Metro/Behaviours/CustomChromeWindowBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class CustomChromeWindowBehavior : Behavior<Window>
{
private AdornerDecorator rootElement;
private IntPtr handle;
private WindowChrome windowChrome;

protected override void OnAttached()
{
Expand All @@ -34,7 +35,7 @@ protected override void OnAttached()
AssociatedObject.StateChanged += (sender, args) => HandleMaximize();
AssociatedObject.Activated += (sender, args) => HandleMaximize();

var windowChrome = new WindowChrome();
windowChrome = new WindowChrome();
windowChrome.ResizeBorderThickness = new Thickness(6);
windowChrome.CaptionHeight = 0;
windowChrome.CornerRadius = new CornerRadius(0);
Expand Down Expand Up @@ -75,9 +76,10 @@ private void HandleMaximize()
{
if (AssociatedObject.WindowState == WindowState.Maximized)
{
windowChrome.ResizeBorderThickness = new Thickness(0);

IntPtr monitor = UnsafeNativeMethods.MonitorFromWindow(handle, Constants.MONITOR_DEFAULTTONEAREST);
if (monitor != IntPtr.Zero)
{
if (monitor != IntPtr.Zero) {
var monitorInfo = new MONITORINFO();
UnsafeNativeMethods.GetMonitorInfo(monitor, monitorInfo);
var metroWindow = AssociatedObject as MetroWindow;
Expand All @@ -89,6 +91,10 @@ private void HandleMaximize()
UnsafeNativeMethods.SetWindowPos(handle, new IntPtr(-2), x, y, cx, cy, 0x0040);
}
}
else
{
windowChrome.ResizeBorderThickness = new Thickness(6);
}
}

private void WmGetMinMaxInfo(System.IntPtr hwnd, System.IntPtr lParam)
Expand Down

2 comments on commit 96d9a7b

@thoemmi
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be SystemParameters2.Current.WindowResizeBorderThickness instead of new Thickness(6)

@punker76
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right. Will do that. thx

Please sign in to comment.