1- // Licensed to the .NET Foundation under one or more agreements.
1+ // Licensed to the .NET Foundation under one or more agreements.
22// The .NET Foundation licenses this file to you under the MIT license.
33// See the LICENSE file in the project root for more information.
44
77using System . Collections . Generic ;
88using System . ComponentModel ;
99using System . Linq ;
10- using System . Reflection ;
1110using System . Windows ;
1211using System . Windows . Automation ;
1312using System . Windows . Automation . Peers ;
1817using System . Windows . Shapes ;
1918using System . Windows . Controls . Primitives ;
2019using System . Windows . Data ;
20+ using System . Windows . Interop ;
2121using ControlzEx . Behaviors ;
2222using ControlzEx . Native ;
2323using ControlzEx . Standard ;
@@ -1279,16 +1279,6 @@ protected override AutomationPeer OnCreateAutomationPeer()
12791279 return new MetroWindowAutomationPeer ( this ) ;
12801280 }
12811281
1282- protected internal IntPtr CriticalHandle
1283- {
1284- get
1285- {
1286- this . VerifyAccess ( ) ;
1287- var value = typeof ( Window ) . GetProperty ( "CriticalHandle" , BindingFlags . NonPublic | BindingFlags . Instance ) ? . GetValue ( this , new object [ 0 ] ) ?? IntPtr . Zero ;
1288- return ( IntPtr ) value ;
1289- }
1290- }
1291-
12921282 private void ClearWindowEvents ( )
12931283 {
12941284 // clear all event handlers first:
@@ -1470,7 +1460,6 @@ internal static void DoWindowTitleThumbMoveOnDragDelta(IMetroThumb thumb, [NotNu
14701460 window . StateChanged += windowOnStateChanged ;
14711461 }
14721462
1473- var criticalHandle = window . CriticalHandle ;
14741463#pragma warning disable 618
14751464 // these lines are from DragMove
14761465 // NativeMethods.SendMessage(criticalHandle, WM.SYSCOMMAND, (IntPtr)SC.MOUSEMOVE, IntPtr.Zero);
@@ -1479,7 +1468,8 @@ internal static void DoWindowTitleThumbMoveOnDragDelta(IMetroThumb thumb, [NotNu
14791468 var wpfPoint = window . PointToScreen ( Mouse . GetPosition ( window ) ) ;
14801469 var x = ( int ) wpfPoint . X ;
14811470 var y = ( int ) wpfPoint . Y ;
1482- NativeMethods . SendMessage ( criticalHandle , WM . NCLBUTTONDOWN , ( IntPtr ) HT . CAPTION , new IntPtr ( x | ( y << 16 ) ) ) ;
1471+ var windowHandle = new WindowInteropHelper ( window ) . EnsureHandle ( ) ;
1472+ NativeMethods . SendMessage ( windowHandle , WM . NCLBUTTONDOWN , ( IntPtr ) HT . CAPTION , new IntPtr ( x | ( y << 16 ) ) ) ;
14831473#pragma warning restore 618
14841474 }
14851475
0 commit comments