Skip to content

Commit 3c2c89f

Browse files
authored
DYN-9829: Fix hidden resize grip in ScriptEditorWindow (#16756)
1 parent 18860ff commit 3c2c89f

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed

src/Libraries/PythonNodeModelsWpf/ScriptEditorWindow.xaml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
Width="600"
1414
MinWidth="500"
1515
MinHeight="450"
16-
ResizeMode="CanResizeWithGrip"
16+
ResizeMode="CanResize"
1717
Style="{DynamicResource DynamoWindowStyle}"
1818
AllowsTransparency="True"
1919
Background="Transparent"
@@ -455,6 +455,33 @@
455455
</Grid>
456456
</Border>
457457
</Grid>
458+
<Border x:Name="WindowResizeHandle"
459+
Grid.Row="4"
460+
HorizontalAlignment="Right"
461+
VerticalAlignment="Bottom"
462+
Width="11"
463+
Height="11"
464+
Margin="0 0 3 3"
465+
Cursor="SizeNWSE"
466+
Background="Transparent"
467+
MouseLeftButtonDown="WindowResizeHandle_OnMouseLeftButtonDown">
468+
<Canvas HorizontalAlignment="Right"
469+
VerticalAlignment="Bottom"
470+
Width="11"
471+
Height="11"
472+
Margin="0">
473+
<Rectangle Width="2" Height="2" Fill="#FFFFFF" Canvas.Left="9"/>
474+
<Rectangle Width="2" Height="2" Fill="#FFFFFF" Canvas.Left="9" Canvas.Top="3"/>
475+
<Rectangle Width="2" Height="2" Fill="#FFFFFF" Canvas.Left="9" Canvas.Top="6"/>
476+
<Rectangle Width="2" Height="2" Fill="#FFFFFF" Canvas.Left="9" Canvas.Top="9"/>
477+
<Rectangle Width="2" Height="2" Fill="#FFFFFF" Canvas.Left="6" Canvas.Top="3"/>
478+
<Rectangle Width="2" Height="2" Fill="#FFFFFF" Canvas.Left="6" Canvas.Top="6"/>
479+
<Rectangle Width="2" Height="2" Fill="#FFFFFF" Canvas.Left="6" Canvas.Top="9"/>
480+
<Rectangle Width="2" Height="2" Fill="#FFFFFF" Canvas.Left="3" Canvas.Top="6"/>
481+
<Rectangle Width="2" Height="2" Fill="#FFFFFF" Canvas.Left="3" Canvas.Top="9"/>
482+
<Rectangle Width="2" Height="2" Fill="#FFFFFF" Canvas.Top="9"/>
483+
</Canvas>
484+
</Border>
458485
</Grid>
459486
</Border>
460487
</Grid>

src/Libraries/PythonNodeModelsWpf/ScriptEditorWindow.xaml.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
using System.Collections.Specialized;
44
using System.ComponentModel;
55
using System.Linq;
6+
using System.Runtime.InteropServices;
67
using System.Windows;
78
using System.Windows.Controls;
89
using System.Windows.Input;
10+
using System.Windows.Interop;
911
using System.Windows.Media;
1012
using System.Xml;
1113
using Dynamo.Configuration;
@@ -50,6 +52,16 @@ public partial class ScriptEditorWindow : ModelessChildWindow
5052
// Reasonable max and min font size values for zooming limits
5153
private const double FONT_MAX_SIZE = 60d;
5254
private const double FONT_MIN_SIZE = 5d;
55+
// Win32 system command and hit-test constants used for resizing
56+
private const int WM_SYSCOMMAND = 0x0112;
57+
private const int SC_SIZE = 0xF000;
58+
private const int HTBOTTOMRIGHT = 0x0008;
59+
60+
/// <summary>
61+
/// Sends a Win32 message to forward a system resize command when the custom resize grip is clicked
62+
/// </summary>
63+
[DllImport("user32.dll")]
64+
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
5365

5466
private const double pythonZoomScalingSliderMaximum = 300d;
5567
private const double pythonZoomScalingSliderMinimum = 25d;
@@ -239,6 +251,7 @@ internal void DockWindow()
239251
editor.IsModified = !IsSaved;
240252

241253
dynamoView.DockWindowInSideBar(this, NodeModel, titleBar);
254+
WindowResizeHandle.Visibility = Visibility.Collapsed;
242255

243256
Analytics.TrackEvent(
244257
Actions.Dock,
@@ -676,11 +689,13 @@ private void ToggleButtons(bool toggle)
676689
{
677690
this.MaximizeButton.Visibility = Visibility.Collapsed;
678691
this.NormalizeButton.Visibility = Visibility.Visible;
692+
this.WindowResizeHandle.Visibility = Visibility.Collapsed;
679693
}
680694
else
681695
{
682696
this.MaximizeButton.Visibility = Visibility.Visible;
683697
this.NormalizeButton.Visibility = Visibility.Collapsed;
698+
this.WindowResizeHandle.Visibility = Visibility.Visible;
684699
}
685700
}
686701

@@ -796,6 +811,17 @@ private void EditText_OnPreviewKeyDown(object sender, KeyEventArgs e)
796811
IsEnterHit = false;
797812
}
798813
}
799-
#endregion
814+
815+
// Handles clicks on the custom resize grip and forwards them as a Win32 bottom-right resize command
816+
private void WindowResizeHandle_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
817+
{
818+
if (WindowState != WindowState.Normal)
819+
return;
820+
821+
var helper = new WindowInteropHelper(this);
822+
SendMessage(helper.Handle, WM_SYSCOMMAND, (IntPtr)(SC_SIZE + HTBOTTOMRIGHT), IntPtr.Zero);
823+
e.Handled = true;
824+
}
825+
#endregion
800826
}
801827
}

0 commit comments

Comments
 (0)