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); }
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; }
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; }
public void TestWidthIsCalculatedCorrectly() { var rect = new RECT() { Left = 1, Right = 10 }; Assert.AreEqual(9, rect.Width); }
public void TestSettingWidthSetsRightCorrectly() { var rect = new RECT() { Left = 1, Right = 10 }; rect.Width = 5; Assert.AreEqual(6, rect.Right); }
public void TestSettingHeightSetsBottomCorrectly() { var rect = new RECT() { Top = 1, Bottom = 10 }; rect.Height = 5; Assert.AreEqual(6, rect.Bottom); }
public void TestHeightIsCalculatedCorrectly() { var rect = new RECT() { Top = 1, Bottom = 10 }; Assert.AreEqual(9, rect.Height); }
public static extern uint SendMessage(IntPtr hWnd, int Msg, int wParam, ref RECT lParam);
public static extern bool IntersectRect(out RECT lprcDst, [In] ref RECT lprcSrc1, [In] ref RECT lprcSrc2);
public RECT(RECT rect) { Left = rect.Left; Top = rect.Top; Right = rect.Right; Bottom = rect.Bottom; }