//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods // Gets the bounding rectangle for this element internal static NativeMethods.Win32Rect GetBoundingRectangle(IntPtr hwnd) { if (!HasGrip(hwnd)) { return(NativeMethods.Win32Rect.Empty); } NativeMethods.Win32Rect client = new NativeMethods.Win32Rect(); if (!Misc.GetClientRectInScreenCoordinates(hwnd, ref client)) { return(NativeMethods.Win32Rect.Empty); } // Get the Size for the Gripper // The size can change at any time so the value cannot be cached NativeMethods.SIZE sizeGrip = WindowsGrip.GetGripSize(hwnd, true); if (Misc.IsLayoutRTL(hwnd)) { // Right to left mirroring style return(new NativeMethods.Win32Rect(client.left, client.bottom - sizeGrip.cy, client.left + sizeGrip.cx, client.bottom)); } else { return(new NativeMethods.Win32Rect(client.right - sizeGrip.cx, client.bottom - sizeGrip.cy, client.right, client.bottom)); } }
internal static bool HasGrip(IntPtr hwnd) { int style = Misc.GetWindowStyle(hwnd); return(Misc.IsBitSet(style, SBARS_SIZEGRIP) || WindowsGrip.IsGripPresent(hwnd, true)); }
// Create the approiate child this can return null if that child does not exist internal ProxyFragment CreateNonClientChild(NonClientItem item) { switch (item) { case NonClientItem.HScrollBar: if (WindowsScrollBar.HasHorizontalScrollBar(_hwnd)) { // the listview needs special handling WindowsListViewScrollBar inherits from WindowsScrollBar // and overrides some of its behavoir if (Misc.ProxyGetClassName(_hwnd) == "SysListView32") { return(new WindowsListViewScrollBar(_hwnd, this, (int)item, NativeMethods.SB_HORZ)); } else { return(new WindowsScrollBar(_hwnd, this, (int)item, NativeMethods.SB_HORZ)); } } break; case NonClientItem.VScrollBar: if (WindowsScrollBar.HasVerticalScrollBar(_hwnd)) { // the listview needs special handling WindowsListViewScrollBar inherits from WindowsScrollBar // and overrides some of its behavoir if (Misc.ProxyGetClassName(_hwnd) == "SysListView32") { return(new WindowsListViewScrollBar(_hwnd, this, (int)item, NativeMethods.SB_VERT)); } else { return(new WindowsScrollBar(_hwnd, this, (int)item, NativeMethods.SB_VERT)); } } break; case NonClientItem.TitleBar: { // Note 2 checks above will succeed for the win32popup menu, hence adding this last one if (WindowsTitleBar.HasTitleBar(_hwnd)) { return(new WindowsTitleBar(_hwnd, this, (int)item)); } break; } case NonClientItem.Menu: { return(CreateNonClientMenu()); } case NonClientItem.Grip: { int style = WindowStyle; if (Misc.IsBitSet(style, NativeMethods.WS_VSCROLL) && Misc.IsBitSet(style, NativeMethods.WS_HSCROLL)) { if (WindowsGrip.IsGripPresent(_hwnd, false)) { return(new WindowsGrip(_hwnd, this, (int)item)); } } break; } default: return(null); } return(null); }