// ------------------------------------------------------ // // Internal Methods // // ------------------------------------------------------ #region Internal Methods // Returns the bounding rectangle of the control. internal static Rect GetBoundingRectangle (IntPtr hwnd, WindowsSlider.SItem item, bool fHorizontal) { NativeMethods.Win32Rect rcChannel = new NativeMethods.Win32Rect (); rcChannel.left = rcChannel.right = rcChannel.top = rcChannel.bottom = 1000; unsafe { XSendMessage.XSend(hwnd, NativeMethods.TBM_GETCHANNELRECT, IntPtr.Zero, new IntPtr(&rcChannel), Marshal.SizeOf(rcChannel.GetType()), XSendMessage.ErrorValue.NoCheck); } if (!Misc.MapWindowPoints(hwnd, IntPtr.Zero, ref rcChannel, 2)) { return Rect.Empty; } NativeMethods.Win32Rect rcThumb = new NativeMethods.Win32Rect(); rcThumb.left = rcThumb.right = rcThumb.top = rcThumb.bottom = 1000; unsafe { XSendMessage.XSend(hwnd, NativeMethods.TBM_GETTHUMBRECT, IntPtr.Zero, new IntPtr(&rcThumb), Marshal.SizeOf(rcThumb.GetType()), XSendMessage.ErrorValue.NoCheck); } if (!Misc.MapWindowPoints(hwnd, IntPtr.Zero, ref rcThumb, 2)) { return Rect.Empty; } if (fHorizontal) { // When WS_EX_RTLREADING is set swap the increment and decrement bars. if (Misc.IsLayoutRTL(hwnd)) { if (item == SItem.LargeDecrement) { item = SItem.LargeIncrement; } else if (item == SItem.LargeIncrement) { item = SItem.LargeDecrement; } } switch (item) { case WindowsSlider.SItem.LargeDecrement : return new Rect (rcChannel.left, rcChannel.top, rcThumb.left - rcChannel.left, rcChannel.bottom - rcChannel.top); case WindowsSlider.SItem.Thumb : return new Rect (rcThumb.left, rcThumb.top, rcThumb.right - rcThumb.left, rcThumb.bottom - rcThumb.top); case WindowsSlider.SItem.LargeIncrement : return new Rect (rcThumb.right, rcChannel.top, rcChannel.right - rcThumb.right, rcChannel.bottom - rcChannel.top); } } else { int dx = rcChannel.bottom - rcChannel.top; int dy = rcChannel.right - rcChannel.left; switch (item) { case WindowsSlider.SItem.LargeDecrement : return new Rect (rcChannel.left, rcChannel.top, dx, rcThumb.top - rcChannel.top); case WindowsSlider.SItem.Thumb : return new Rect (rcThumb.left, rcThumb.top, rcThumb.right - rcThumb.left, rcThumb.bottom - rcThumb.top); case WindowsSlider.SItem.LargeIncrement : return new Rect (rcChannel.left, rcThumb.bottom, dx, dy); } } return Rect.Empty; }
// ------------------------------------------------------ // // Private Methods // // ------------------------------------------------------ #region Private Methods private unsafe NativeMethods.Win32Rect BoundingRect() { NativeMethods.Win32Rect rectW32 = new NativeMethods.Win32Rect(); if (!XSendMessage.XSend(_hwnd, NativeMethods.TCM_GETITEMRECT, new IntPtr(_item), new IntPtr(&rectW32), Marshal.SizeOf(rectW32.GetType()), XSendMessage.ErrorValue.Zero)) { return NativeMethods.Win32Rect.Empty; } return Misc.MapWindowPoints(_hwnd, IntPtr.Zero, ref rectW32, 2) ? rectW32 : NativeMethods.Win32Rect.Empty; }
internal unsafe NativeMethods.Win32Rect GetGroupRect() { NativeMethods.Win32Rect rect = new NativeMethods.Win32Rect(); bool isCollapsed = WindowsListViewGroup.IsCollapsed(_hwnd, _groupID); rect.top = isCollapsed ? NativeMethods.LVGGR_HEADER : NativeMethods.LVGGR_GROUP; XSendMessage.XSend(_hwnd, NativeMethods.LVM_GETGROUPRECT, new IntPtr(_groupID), new IntPtr(&rect), Marshal.SizeOf(rect.GetType())); Misc.MapWindowPoints(_hwnd, IntPtr.Zero, ref rect, 2); return rect; }