// Not all the non-client children exist for every window that has a non-client area. // This gets the next child that is actually there. private ProxyFragment ReturnNextNonClientChild(bool next, NonClientItem start) { ProxyFragment el; for (int i = (int)start; i > (int)NonClientItem.MIN && i < (int)NonClientItem.MAX; i += next ? 1 : -1) { el = CreateNonClientChild((NonClientItem)i); if (el != null) { return(el); } } return(null); }
// 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; }
// Not all the non-client children exist for every window that has a non-client area. // This gets the next child that is actually there. private ProxyFragment ReturnNextNonClientChild (bool next, NonClientItem start) { ProxyFragment el; for (int i = (int) start; i > (int) NonClientItem.MIN && i < (int) NonClientItem.MAX; i += next ? 1 : -1) { el = CreateNonClientChild ((NonClientItem) i); if (el != null) return el; } return null; }
private static void RaiseEventsOnScroll(IntPtr hwnd, int eventId, object idProp, int idObject, int idChild) { if ((idProp == ScrollPattern.VerticalScrollPercentProperty && idObject != NativeMethods.OBJID_VSCROLL) || (idProp == ScrollPattern.HorizontalScrollPercentProperty && idObject != NativeMethods.OBJID_HSCROLL)) { return; } ProxyFragment el = new NonClientArea(hwnd); if (el == null) { return; } if (idProp == InvokePattern.InvokedEvent) { NonClientItem item = idObject == NativeMethods.OBJID_HSCROLL ? NonClientItem.HScrollBar : NonClientItem.VScrollBar; int sbFlag = idObject == NativeMethods.OBJID_HSCROLL ? NativeMethods.SB_HORZ : NativeMethods.SB_VERT; ProxyFragment scrollBar = new WindowsScrollBar(hwnd, el, (int)item, sbFlag); if (scrollBar != null) { ProxySimple scrollBarBit = WindowsScrollBarBits.CreateFromChildId(hwnd, scrollBar, idChild, sbFlag); if (scrollBarBit != null) { scrollBarBit.DispatchEvents(eventId, idProp, idObject, idChild); } } return; } if (eventId == NativeMethods.EventObjectStateChange && idProp == ValuePattern.IsReadOnlyProperty) { if (idChild == 0) { // if (idObject == NativeMethods.OBJID_HSCROLL || idObject == NativeMethods.OBJID_VSCROLL) { idObject = NativeMethods.OBJID_WINDOW; } el.DispatchEvents(eventId, idProp, idObject, idChild); } return; } if (idProp == ValuePattern.ValueProperty && eventId == NativeMethods.EVENT_OBJECT_VALUECHANGE) { NonClientItem item = idObject == NativeMethods.OBJID_HSCROLL ? NonClientItem.HScrollBar : NonClientItem.VScrollBar; WindowsScrollBar scrollBar = new WindowsScrollBar(hwnd, el, (int)item, idObject == NativeMethods.OBJID_HSCROLL ? NativeMethods.SB_HORZ : NativeMethods.SB_VERT); scrollBar.DispatchEvents(0, ValuePattern.ValueProperty, NativeMethods.OBJID_CLIENT, 0); return; } if (Misc.GetClassName(hwnd) == "ComboLBox") { el = (ProxyFragment)WindowsListBox.Create(hwnd, 0); } if (el != null) { el.DispatchEvents(eventId, idProp, idObject, idChild); } }
// 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); }
private static void RaiseEventsOnScroll(IntPtr hwnd, int eventId, object idProp, int idObject, int idChild) { if ((idProp == ScrollPattern.VerticalScrollPercentProperty && idObject != NativeMethods.OBJID_VSCROLL) || (idProp == ScrollPattern.HorizontalScrollPercentProperty && idObject != NativeMethods.OBJID_HSCROLL)) { return; } ProxyFragment el = new NonClientArea(hwnd); if (el == null) { return; } if (idProp == InvokePattern.InvokedEvent) { NonClientItem item = idObject == NativeMethods.OBJID_HSCROLL ? NonClientItem.HScrollBar : NonClientItem.VScrollBar; int sbFlag = idObject == NativeMethods.OBJID_HSCROLL ? NativeMethods.SB_HORZ : NativeMethods.SB_VERT; ProxyFragment scrollBar = new WindowsScrollBar(hwnd, el, (int)item, sbFlag); if (scrollBar != null) { ProxySimple scrollBarBit = WindowsScrollBarBits.CreateFromChildId(hwnd, scrollBar, idChild, sbFlag); if (scrollBarBit != null) { scrollBarBit.DispatchEvents(eventId, idProp, idObject, idChild); } } return; } if (eventId == NativeMethods.EventObjectStateChange && idProp == ValuePattern.IsReadOnlyProperty) { if (idChild == 0) { // This code is never exercised. The code in User needs to change to send // EventObjectStateChange with a client ID of zero // // UIA works differently than MSAA. Events are set for elements rather than hwnd // Scroll bar are processed the same way whatever they are part of the non client area // or stand alone hwnd. OBJID_HSCROLL and OBJID_VSCROLL are mapped to OBJID_WINDOW // so they behave the same for NC and hwnd SB. // Parameters are setup so that the dispatch will send the proper notification and // recursively will send notifications to all of the children if (idObject == NativeMethods.OBJID_HSCROLL || idObject == NativeMethods.OBJID_VSCROLL) { idObject = NativeMethods.OBJID_WINDOW; } el.DispatchEvents(eventId, idProp, idObject, idChild); } return; } if (idProp == ValuePattern.ValueProperty && eventId == NativeMethods.EVENT_OBJECT_VALUECHANGE) { NonClientItem item = idObject == NativeMethods.OBJID_HSCROLL ? NonClientItem.HScrollBar : NonClientItem.VScrollBar; WindowsScrollBar scrollBar = new WindowsScrollBar(hwnd, el, (int)item, idObject == NativeMethods.OBJID_HSCROLL ? NativeMethods.SB_HORZ : NativeMethods.SB_VERT); scrollBar.DispatchEvents(0, ValuePattern.ValueProperty, NativeMethods.OBJID_CLIENT, 0); return; } if (Misc.GetClassName(hwnd) == "ComboLBox") { el = (ProxyFragment)WindowsListBox.Create(hwnd, 0); } if (el != null) { el.DispatchEvents(eventId, idProp, idObject, idChild); } }