Fixed an issue where the gadget would not be movable on an extra monitor positioned to the left of the primary monitor.
authorpaulwerelds
Mon, 04 Oct 2010 06:46:55 +0000
changeset 20808635c9dac04
parent 207 708f7aeddb30
child 209 dee42c887ab0
Fixed an issue where the gadget would not be movable on an extra monitor positioned to the left of the primary monitor.
GUI/GadgetWindow.cs
     1.1 --- a/GUI/GadgetWindow.cs	Sat Oct 02 20:03:59 2010 +0000
     1.2 +++ b/GUI/GadgetWindow.cs	Mon Oct 04 06:46:55 2010 +0000
     1.3 @@ -123,8 +123,9 @@
     1.4              message.Result = (IntPtr)HitResult.Caption;
     1.5              if (HitTest != null) {
     1.6                Point p = new Point(
     1.7 -                (int)((uint)message.LParam & 0xFFFF) - location.X,
     1.8 -                (int)(((uint)message.LParam >> 16) & 0xFFFF) - location.Y);
     1.9 +                Macros.GET_X_LPARAM(message.LParam) - location.X,
    1.10 +                Macros.GET_Y_LPARAM(message.LParam) - location.Y
    1.11 +              );
    1.12                HitTestEventArgs e = new HitTestEventArgs(p, HitResult.Caption);
    1.13                HitTest(this, e);
    1.14                message.Result = (IntPtr)e.HitResult;
    1.15 @@ -421,6 +422,30 @@
    1.16        DWMWA_LAST
    1.17      }
    1.18  
    1.19 +    /// <summary>
    1.20 +    /// Some macros imported and converted from the Windows SDK
    1.21 +    /// </summary>
    1.22 +    private static class Macros {
    1.23 +      public static UInt16 LOWORD(IntPtr l) {
    1.24 +        return ((UInt16) (((UInt64) (l)) & 0xffff));
    1.25 +      }
    1.26 +      
    1.27 +      public static UInt16 HIWORD(IntPtr l) {
    1.28 +        return ((UInt16) ((((UInt64) (l)) >> 16) & 0xffff));
    1.29 +      }
    1.30 +
    1.31 +      public static int GET_X_LPARAM(IntPtr lp) {
    1.32 +        return ((int) (short) LOWORD(lp));
    1.33 +      }
    1.34 +
    1.35 +      public static int GET_Y_LPARAM(IntPtr lp) {
    1.36 +        return ((int) (short) HIWORD(lp));
    1.37 +      }
    1.38 +    }
    1.39 +
    1.40 +    /// <summary>
    1.41 +    /// Imported native methods
    1.42 +    /// </summary>
    1.43      private static class NativeMethods {
    1.44        private const string USER = "user32.dll";
    1.45        private const string GDI = "gdi32.dll";