1
- // Licensed to the .NET Foundation under one or more agreements.
1
+ // Licensed to the .NET Foundation under one or more agreements.
2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
// See the LICENSE file in the project root for more information.
4
4
7
7
using System . Collections . Generic ;
8
8
using System . ComponentModel ;
9
9
using System . Linq ;
10
- using System . Reflection ;
11
10
using System . Windows ;
12
11
using System . Windows . Automation ;
13
12
using System . Windows . Automation . Peers ;
18
17
using System . Windows . Shapes ;
19
18
using System . Windows . Controls . Primitives ;
20
19
using System . Windows . Data ;
20
+ using System . Windows . Interop ;
21
21
using ControlzEx . Behaviors ;
22
22
using ControlzEx . Native ;
23
23
using ControlzEx . Standard ;
@@ -1279,16 +1279,6 @@ protected override AutomationPeer OnCreateAutomationPeer()
1279
1279
return new MetroWindowAutomationPeer ( this ) ;
1280
1280
}
1281
1281
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
-
1292
1282
private void ClearWindowEvents ( )
1293
1283
{
1294
1284
// clear all event handlers first:
@@ -1470,7 +1460,6 @@ internal static void DoWindowTitleThumbMoveOnDragDelta(IMetroThumb thumb, [NotNu
1470
1460
window . StateChanged += windowOnStateChanged ;
1471
1461
}
1472
1462
1473
- var criticalHandle = window . CriticalHandle ;
1474
1463
#pragma warning disable 618
1475
1464
// these lines are from DragMove
1476
1465
// NativeMethods.SendMessage(criticalHandle, WM.SYSCOMMAND, (IntPtr)SC.MOUSEMOVE, IntPtr.Zero);
@@ -1479,7 +1468,8 @@ internal static void DoWindowTitleThumbMoveOnDragDelta(IMetroThumb thumb, [NotNu
1479
1468
var wpfPoint = window . PointToScreen ( Mouse . GetPosition ( window ) ) ;
1480
1469
var x = ( int ) wpfPoint . X ;
1481
1470
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 ) ) ) ;
1483
1473
#pragma warning restore 618
1484
1474
}
1485
1475
0 commit comments