// Static Create method called by the event tracker system internal static void RaiseEvents(IntPtr hwnd, int eventId, object idProp, int idObject, int idChild) { if (idObject != NativeMethods.OBJID_VSCROLL && idObject != NativeMethods.OBJID_HSCROLL) { ProxySimple el; if (IsInsideOfIPAddress(hwnd)) { el = new ByteEditBoxOverride(hwnd, idChild); } else { el = new WindowsEditBox(hwnd, null, 0); // If this is an Edit control inside of a Microsoft Spinner, need to treat the property // changes for as property changes on the whole Microsoft Spinner, not on the element // of the Microsoft Spinner. Microsoft Spinner raise WinEvents on the Edit portion of // the spinner and not the UpDown portion like the Win32 Spinner. IntPtr hwndParent = NativeMethodsSetLastError.GetAncestor(hwnd, NativeMethods.GA_PARENT); if (hwndParent != IntPtr.Zero) { // Test for spinner - Create checks if the element is a spinner ProxySimple spinner = (ProxySimple)WinformsSpinner.Create(hwndParent, 0); if (spinner != null) { el = spinner; } } } el.DispatchEvents(eventId, idProp, idObject, idChild); } }
// Note: GetWindowLong is used in the win32 proxy only to retrieve the style // The wrapper is required as the signature for the function in 32 bits and 64 bit is different. internal static Int32 GetWindowLong(IntPtr hWnd, int nIndex, out int error) { int iResult = 0; IntPtr result = IntPtr.Zero; error = 0; if (IntPtr.Size == 4) { // use GetWindowLong iResult = NativeMethodsSetLastError.GetWindowLong(hWnd, nIndex); error = Marshal.GetLastWin32Error(); result = new IntPtr(iResult); } else { // use GetWindowLongPtr result = NativeMethodsSetLastError.GetWindowLongPtr(hWnd, nIndex); error = Marshal.GetLastWin32Error(); iResult = NativeMethods.IntPtrToInt32(result); } if ((result == IntPtr.Zero) && (error != 0)) { // To be consistent with out other PInvoke wrappers // we should "throw" here. But we don't want to // introduce new "throws" w/o time to follow up on any // new problems that causes. Debug.WriteLine("GetWindowLong failed. Error = " + error); // throw new System.ComponentModel.Win32Exception(error); } return(iResult); }
private bool OnCommandBar() { IntPtr hwndParent = NativeMethodsSetLastError.GetAncestor(_hwnd, NativeMethods.GA_PARENT); if (hwndParent != IntPtr.Zero) { return(Misc.GetClassName(hwndParent).Equals("MsoCommandBar")); } return(false); }
// Detect if our combobox is hosted inside of comboex // This is important to know becuase: // Real styles will be provided by comboex // comboex supplies the edit static internal IntPtr HostedByComboEx(IntPtr hwnd) { IntPtr hwndEx = NativeMethodsSetLastError.GetAncestor(hwnd, NativeMethods.GA_PARENT); if ((IntPtr.Zero != hwndEx) && IsComboEx(hwndEx)) { return(hwndEx); } return(IntPtr.Zero); }
// Handles combo's edit portion specific events // as combo-specific events private static void EditPortionEvents(IntPtr hwnd, int eventId, object idProp, int idObject, int idChild) { // Get hwnd of the combo-box IntPtr hwndCombo = NativeMethodsSetLastError.GetAncestor(hwnd, NativeMethods.GA_PARENT); if (hwndCombo != IntPtr.Zero) { ProxySimple el = (ProxySimple)Create(hwndCombo, 0); el.DispatchEvents(eventId, idProp, idObject, idChild); } }
// ------------------------------------------------------ // // Private Methods // //------------------------------------------------------ #region Private Methods private IntPtr GetTabParent() { IntPtr hwndParent = NativeMethodsSetLastError.GetAncestor(_hwnd, NativeMethods.GA_PARENT); if (hwndParent != IntPtr.Zero) { // Test for tab control hwndParent = Misc.ProxyGetClassName(hwndParent).Contains("SysTabControl32") ? hwndParent : IntPtr.Zero; } return(hwndParent); }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods internal bool IsInsideOfTab() { IntPtr hwndParent = NativeMethodsSetLastError.GetAncestor(_hwnd, NativeMethods.GA_PARENT); if (hwndParent != IntPtr.Zero) { // Test for tab control return(Misc.ProxyGetClassName(hwndParent).Contains("SysTabControl32")); } return(false); }
// Scroll the specified headerItem horizontally into view. internal void ScrollIntoView(HeaderItem headerItem) { // Check if the parent is a ListView IntPtr hwndParent = NativeMethodsSetLastError.GetAncestor(_hwnd, NativeMethods.GA_PARENT); if (hwndParent != IntPtr.Zero) { if (Misc.GetClassName(hwndParent).IndexOf("SysListView32", StringComparison.Ordinal) >= 0) { // Determine the number of pixels or columns to scroll horizontally. int pixels = 0; int columns = 0; // Get first and last visible header items. HeaderItem firstVisibleHeaderItem; HeaderItem lastVisibleHeaderItem; GetVisibleHeaderItemRange(out firstVisibleHeaderItem, out lastVisibleHeaderItem); if (firstVisibleHeaderItem != null && firstVisibleHeaderItem._item > headerItem._item) { // Scroll backward. pixels = (int)(headerItem.BoundingRectangle.Left - firstVisibleHeaderItem.BoundingRectangle.Left); columns = headerItem._item - firstVisibleHeaderItem._item; } else if (lastVisibleHeaderItem != null && headerItem._item > lastVisibleHeaderItem._item) { // Scroll forward. pixels = (int)(headerItem.BoundingRectangle.Left - lastVisibleHeaderItem.BoundingRectangle.Left); columns = headerItem._item - lastVisibleHeaderItem._item; } int horizontalScrollAmount = 0; if (WindowsListView.IsListMode(hwndParent)) { // In list mode, LVM_SCROLL uses a column count. horizontalScrollAmount = columns; } else if (WindowsListView.IsDetailMode(hwndParent)) { // In details mode, LVM_SCROLL uses a pixel count. horizontalScrollAmount = pixels; } if (horizontalScrollAmount != 0) { Misc.ProxySendMessage(hwndParent, NativeMethods.LVM_SCROLL, new IntPtr(horizontalScrollAmount), IntPtr.Zero); } } } }
private static bool IsInsideOfListView(IntPtr hwnd) { IntPtr hwndParent = NativeMethodsSetLastError.GetAncestor(hwnd, NativeMethods.GA_PARENT); if (hwndParent != IntPtr.Zero) { string classname = Misc.GetClassName(hwndParent); if (classname.Equals("SysListView32")) { return(true); } } return(false); }
private bool IsInsideOfSpinner() { IntPtr hwndParent = NativeMethodsSetLastError.GetAncestor(_hwnd, NativeMethods.GA_PARENT); if (hwndParent != IntPtr.Zero) { // Test for spinner - Create checks if the element is a spinner if (WinformsSpinner.Create(hwndParent, 0) != null) { return(true); } } return(WindowsSpinner.IsSpinnerEdit(_hwnd)); }
// Process events for the associated UpDown control, and relay // them to the WindowsTab control instead. internal static void UpDownControlRaiseEvents( IntPtr hwnd, int eventId, object idProp, int idObject, int idChild) { if (eventId == NativeMethods.EventObjectValueChange && idProp == ScrollPattern.HorizontalScrollPercentProperty) { IntPtr hwndParent = NativeMethodsSetLastError.GetAncestor(hwnd, NativeMethods.GA_PARENT); if (hwndParent != IntPtr.Zero && Misc.ProxyGetClassName(hwndParent).Contains("SysTabControl32")) { WindowsTab el = new WindowsTab(hwndParent, null, 0); el.DispatchEvents(eventId, idProp, 0, 0); } } }
private bool IsInsideOfCombo() { IntPtr hwndParent = NativeMethodsSetLastError.GetAncestor(_hwnd, NativeMethods.GA_PARENT); if (hwndParent == IntPtr.Zero) { return(false); } // Test for combo NativeMethods.COMBOBOXINFO cbInfo = new NativeMethods.COMBOBOXINFO(NativeMethods.comboboxInfoSize); if (WindowsComboBox.GetComboInfo(hwndParent, ref cbInfo) && cbInfo.hwndItem == _hwnd) { return(true); } return(false); }
// Wrapper on top of Win32's GetComboInfo static internal bool GetComboInfo(IntPtr hwnd, ref NativeMethods.COMBOBOXINFO cbInfo) { bool result = Misc.GetComboBoxInfo(hwnd, ref cbInfo); if (result) { // some combo boxes do not have an edit portion // instead they return combo hwnd in the item // to make our life easier set hwndItem to IntPtr.Zero if (cbInfo.hwndItem == cbInfo.hwndCombo) { cbInfo.hwndItem = IntPtr.Zero; } // Possible that Combo is hosted by ComboboxEx32 // hence GetComboBoxInfo did not provide us with edit. // We should try to detect it ourselves if (cbInfo.hwndItem == IntPtr.Zero && IsComboEx(NativeMethodsSetLastError.GetAncestor(hwnd, NativeMethods.GA_PARENT))) { cbInfo.hwndItem = Misc.FindWindowEx(hwnd, IntPtr.Zero, "EDIT", null); if (cbInfo.hwndItem != IntPtr.Zero) { result = Misc.GetWindowRect(cbInfo.hwndItem, ref cbInfo.rcItem); if (result) { result = Misc.MapWindowPoints(_hwndDesktop, hwnd, ref cbInfo.rcItem, 2); } if (!result) { cbInfo.rcItem = NativeMethods.Win32Rect.Empty; } } } } return(result); }
internal static void RaiseEvents(IntPtr hwnd, int eventId, object idProp, int idObject, int idChild) { if (idObject != NativeMethods.OBJID_VSCROLL && idObject != NativeMethods.OBJID_HSCROLL) { ProxyFragment header = new WindowsSysHeader(hwnd); AutomationProperty property = idProp as AutomationProperty; if (property == TablePattern.ColumnHeadersProperty || property == TablePattern.RowHeadersProperty) { // Check if the parent is a ListView IntPtr hwndParent = NativeMethodsSetLastError.GetAncestor(hwnd, NativeMethods.GA_PARENT); if (hwndParent != IntPtr.Zero) { if (Misc.GetClassName(hwndParent).IndexOf("SysListView32", StringComparison.Ordinal) >= 0) { // Notify the Listview that the header Change WindowsListView wlv = (WindowsListView)WindowsListView.Create(hwndParent, 0); if (wlv != null) { wlv.DispatchEvents(eventId, idProp, idObject, idChild); } } } } else { if (idProp == InvokePattern.InvokedEvent) { ProxySimple headerItem = new HeaderItem(hwnd, header, idChild); headerItem.DispatchEvents(eventId, idProp, idObject, idChild); } else { header.DispatchEvents(eventId, idProp, idObject, idChild); } } } }