Example #1
0
 public void TestUnpackParamsAreTheSameAsOriginal()
 {
     var packager = new CoordsPackager();
     var param = new RECT { Left = 1, Top = 2, Right = 3, Bottom = 4 };
     var packedParams = packager.PackParams(param);
     var result = packager.UnpackParams(packedParams.LParam, packedParams.WParam);
     Assert.AreEqual(param, result);
 }
Example #2
0
 public RECT UnpackParams(IntPtr lParam, IntPtr wParam)
 {
     var p1 = (uint)wParam;
     var p2 = (uint)lParam;
     var result = new RECT
         {
             Left = (int) (p1 >> BitsToShift),
             Top = (int) (p1 & BitMask),
             Right = (int) (p2 >> BitsToShift),
             Bottom = (int) (p2 & BitMask)
         };
     return result;
 }
Example #3
0
        public MessageParams PackParams(RECT rect)
        {
            // C++ would unpack it like this:
            //const unsigned int p1 = (unsigned int)wParam;
            //const unsigned int p2 = (unsigned int)lParam;
            //buttonsRect.left = p1 >> 16;
            //buttonsRect.top = p1 & 0xFFFF;
            //buttonsRect.right = p2 >> 16;
            //buttonsRect.bottom = p2 & 0xFFFF;
            var result = new MessageParams
                {
                    WParam = (IntPtr) ((((uint) rect.Left) << BitsToShift) | (((uint) rect.Top) & BitMask)),
                    LParam = (IntPtr) ((((uint) rect.Right) << BitsToShift) | (((uint) rect.Bottom) & BitMask))
                };

            return result;
        }
Example #4
0
 public void TestWidthIsCalculatedCorrectly()
 {
     var rect = new RECT() { Left = 1, Right = 10 };
     Assert.AreEqual(9, rect.Width);
 }
Example #5
0
 public void TestSettingWidthSetsRightCorrectly()
 {
     var rect = new RECT() { Left = 1, Right = 10 };
     rect.Width = 5;
     Assert.AreEqual(6, rect.Right);
 }
Example #6
0
 public void TestSettingHeightSetsBottomCorrectly()
 {
     var rect = new RECT() { Top = 1, Bottom = 10 };
     rect.Height = 5;
     Assert.AreEqual(6, rect.Bottom);
 }
Example #7
0
 public void TestHeightIsCalculatedCorrectly()
 {
     var rect = new RECT() { Top = 1, Bottom = 10 };
     Assert.AreEqual(9, rect.Height);
 }
Example #8
0
 public static extern uint SendMessage(IntPtr hWnd, int Msg, int wParam, ref RECT lParam);
Example #9
0
 public static extern bool IntersectRect(out RECT lprcDst, [In] ref RECT lprcSrc1, [In] ref RECT lprcSrc2);
Example #10
0
 public RECT(RECT rect)
 {
     Left = rect.Left;
     Top = rect.Top;
     Right = rect.Right;
     Bottom = rect.Bottom;
 }