public DCMapping(HandleRef hDC, Rectangle bounds) { if (hDC.Handle == IntPtr.Zero) { throw new ArgumentNullException("hDC"); } System.Windows.Forms.NativeMethods.POINT point = new System.Windows.Forms.NativeMethods.POINT(); HandleRef nullHandleRef = System.Windows.Forms.NativeMethods.NullHandleRef; System.Windows.Forms.NativeMethods.RegionFlags nULLREGION = System.Windows.Forms.NativeMethods.RegionFlags.NULLREGION; this.translatedBounds = bounds; this.graphics = null; this.dc = DeviceContext.FromHdc(hDC.Handle); this.dc.SaveHdc(); System.Windows.Forms.SafeNativeMethods.GetViewportOrgEx(hDC, point); HandleRef hRgn = new HandleRef(null, System.Windows.Forms.SafeNativeMethods.CreateRectRgn(point.x + bounds.Left, point.y + bounds.Top, point.x + bounds.Right, point.y + bounds.Bottom)); try { nullHandleRef = new HandleRef(this, System.Windows.Forms.SafeNativeMethods.CreateRectRgn(0, 0, 0, 0)); int clipRgn = System.Windows.Forms.SafeNativeMethods.GetClipRgn(hDC, nullHandleRef); System.Windows.Forms.NativeMethods.POINT point2 = new System.Windows.Forms.NativeMethods.POINT(); System.Windows.Forms.SafeNativeMethods.SetViewportOrgEx(hDC, point.x + bounds.Left, point.y + bounds.Top, point2); if (clipRgn != 0) { System.Windows.Forms.NativeMethods.RECT clipRect = new System.Windows.Forms.NativeMethods.RECT(); if (System.Windows.Forms.SafeNativeMethods.GetRgnBox(nullHandleRef, ref clipRect) == 2) { System.Windows.Forms.SafeNativeMethods.CombineRgn(hRgn, hRgn, nullHandleRef, 1); } } else { System.Windows.Forms.SafeNativeMethods.DeleteObject(nullHandleRef); nullHandleRef = new HandleRef(null, IntPtr.Zero); nULLREGION = System.Windows.Forms.NativeMethods.RegionFlags.SIMPLEREGION; } System.Windows.Forms.SafeNativeMethods.SelectClipRgn(hDC, hRgn); } catch (Exception exception) { if (System.Windows.Forms.ClientUtils.IsSecurityOrCriticalException(exception)) { throw; } this.dc.RestoreHdc(); this.dc.Dispose(); } finally { System.Windows.Forms.SafeNativeMethods.DeleteObject(hRgn); if (nullHandleRef.Handle != IntPtr.Zero) { System.Windows.Forms.SafeNativeMethods.DeleteObject(nullHandleRef); } } }
public Point GetPoint(PointProperty prop) { if (!System.Windows.Forms.ClientUtils.IsEnumValid(prop, (int)prop, 0xd49, 0xd50)) { throw new InvalidEnumArgumentException("prop", (int)prop, typeof(PointProperty)); } System.Windows.Forms.NativeMethods.POINT pPoint = new System.Windows.Forms.NativeMethods.POINT(); this.lastHResult = System.Windows.Forms.SafeNativeMethods.GetThemePosition(new HandleRef(this, this.Handle), this.part, this.state, (int)prop, pPoint); return(new Point(pPoint.x, pPoint.y)); }
public int NearestIndex(Point pt) { System.Windows.Forms.NativeMethods.POINT wParam = new System.Windows.Forms.NativeMethods.POINT { x = pt.X, y = pt.Y }; System.Windows.Forms.NativeMethods.LVINSERTMARK lParam = new System.Windows.Forms.NativeMethods.LVINSERTMARK(); System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this.listView, this.listView.Handle), 0x10a8, wParam, lParam); return(lParam.iItem); }
public int NearestIndex(Point pt) { System.Windows.Forms.NativeMethods.POINT wParam = new System.Windows.Forms.NativeMethods.POINT { x = pt.X, y = pt.Y }; System.Windows.Forms.NativeMethods.LVINSERTMARK lParam = new System.Windows.Forms.NativeMethods.LVINSERTMARK(); System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this.listView, this.listView.Handle), 0x10a8, wParam, lParam); return lParam.iItem; }
private MouseEventArgs TranslateMouseEvent(Control child, MouseEventArgs e) { if ((child != null) && base.IsHandleCreated) { System.Windows.Forms.NativeMethods.POINT pt = new System.Windows.Forms.NativeMethods.POINT(e.X, e.Y); System.Windows.Forms.UnsafeNativeMethods.MapWindowPoints(new HandleRef(child, child.Handle), new HandleRef(this, base.Handle), pt, 1); return(new MouseEventArgs(e.Button, e.Clicks, pt.x, pt.y, e.Delta)); } return(e); }
private void ShowContextMenu() { if ((this.contextMenu != null) || (this.contextMenuStrip != null)) { System.Windows.Forms.NativeMethods.POINT pt = new System.Windows.Forms.NativeMethods.POINT(); System.Windows.Forms.UnsafeNativeMethods.GetCursorPos(pt); System.Windows.Forms.UnsafeNativeMethods.SetForegroundWindow(new HandleRef(this.window, this.window.Handle)); if (this.contextMenu != null) { this.contextMenu.OnPopup(EventArgs.Empty); System.Windows.Forms.SafeNativeMethods.TrackPopupMenuEx(new HandleRef(this.contextMenu, this.contextMenu.Handle), 0x48, pt.x, pt.y, new HandleRef(this.window, this.window.Handle), null); System.Windows.Forms.UnsafeNativeMethods.PostMessage(new HandleRef(this.window, this.window.Handle), 0, IntPtr.Zero, IntPtr.Zero); } else if (this.contextMenuStrip != null) { this.contextMenuStrip.ShowInTaskbar(pt.x, pt.y); } } }
protected override void WndProc(ref Message m) { if ((m.Msg == 0x84) && this.SizingGrip) { Rectangle sizeGripBounds = this.SizeGripBounds; int x = System.Windows.Forms.NativeMethods.Util.LOWORD(m.LParam); int y = System.Windows.Forms.NativeMethods.Util.HIWORD(m.LParam); if (sizeGripBounds.Contains(base.PointToClient(new Point(x, y)))) { HandleRef rootHWnd = WindowsFormsUtils.GetRootHWnd(this); if ((rootHWnd.Handle != IntPtr.Zero) && !System.Windows.Forms.UnsafeNativeMethods.IsZoomed(rootHWnd)) { System.Windows.Forms.NativeMethods.POINT point; System.Windows.Forms.NativeMethods.RECT rect = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.UnsafeNativeMethods.GetClientRect(rootHWnd, ref rect); if (this.RightToLeft == RightToLeft.Yes) { point = new System.Windows.Forms.NativeMethods.POINT(this.SizeGripBounds.Left, this.SizeGripBounds.Bottom); } else { point = new System.Windows.Forms.NativeMethods.POINT(this.SizeGripBounds.Right, this.SizeGripBounds.Bottom); } System.Windows.Forms.UnsafeNativeMethods.MapWindowPoints(new HandleRef(this, base.Handle), rootHWnd, point, 1); int num3 = Math.Abs((int)(rect.bottom - point.y)); int num4 = Math.Abs((int)(rect.right - point.x)); if ((this.RightToLeft != RightToLeft.Yes) && ((num4 + num3) < 2)) { m.Result = (IntPtr)0x11; return; } } } } base.WndProc(ref m); }
public static extern bool MoveToEx(HandleRef hdc, int x, int y, System.Windows.Forms.NativeMethods.POINT pt);
public static extern bool GetViewportOrgEx(HandleRef hDC, [In, Out] System.Windows.Forms.NativeMethods.POINT point);
public static extern int GetThemePosition(HandleRef hTheme, int iPartId, int iStateId, int iPropId, [Out] System.Windows.Forms.NativeMethods.POINT pPoint);
protected override void WndProc(ref Message m) { int msg = m.Msg; switch (msg) { case 0x4e: case 0x204e: { System.Windows.Forms.NativeMethods.NMHDR lParam = (System.Windows.Forms.NativeMethods.NMHDR) m.GetLParam(typeof(System.Windows.Forms.NativeMethods.NMHDR)); switch (lParam.code) { case -521: { System.Windows.Forms.NativeMethods.WINDOWPLACEMENT placement = new System.Windows.Forms.NativeMethods.WINDOWPLACEMENT(); System.Windows.Forms.UnsafeNativeMethods.GetWindowPlacement(new HandleRef(null, lParam.hwndFrom), ref placement); if (((placement.rcNormalPosition_left != 0) || (placement.rcNormalPosition_top != 0)) || (this.hotItem == -1)) { goto Label_02BE; } int num = 0; for (int i = 0; i <= this.hotItem; i++) { num += this.buttonsCollection[i].GetButtonWidth(); } int num3 = placement.rcNormalPosition_right - placement.rcNormalPosition_left; int num4 = placement.rcNormalPosition_bottom - placement.rcNormalPosition_top; int x = (base.Location.X + num) + 1; int y = base.Location.Y + (this.ButtonSize.Height / 2); System.Windows.Forms.NativeMethods.POINT pt = new System.Windows.Forms.NativeMethods.POINT(x, y); System.Windows.Forms.UnsafeNativeMethods.ClientToScreen(new HandleRef(this, base.Handle), pt); if (pt.y < SystemInformation.WorkingArea.Y) { pt.y += (this.ButtonSize.Height / 2) + 1; } if ((pt.y + num4) > SystemInformation.WorkingArea.Height) { pt.y -= ((this.ButtonSize.Height / 2) + num4) + 1; } if ((pt.x + num3) > SystemInformation.WorkingArea.Right) { pt.x -= (this.ButtonSize.Width + num3) + 2; } System.Windows.Forms.SafeNativeMethods.SetWindowPos(new HandleRef(null, lParam.hwndFrom), System.Windows.Forms.NativeMethods.NullHandleRef, pt.x, pt.y, 0, 0, 0x15); m.Result = (IntPtr) 1; return; } case -520: this.WmNotifyNeedTextA(ref m); m.Result = (IntPtr) 1; return; case -530: if (Marshal.SystemDefaultCharSize != 2) { break; } this.WmNotifyNeedText(ref m); m.Result = (IntPtr) 1; return; case -706: m.Result = (IntPtr) 1; goto Label_02BE; case -713: this.WmNotifyHotItemChange(ref m); goto Label_02BE; case -710: this.WmNotifyDropDown(ref m); goto Label_02BE; } break; } default: if (msg == 0x2111) { this.WmReflectCommand(ref m); } break; } Label_02BE: base.WndProc(ref m); }
private MouseEventArgs TranslateMouseEvent(Control child, MouseEventArgs e) { if ((child != null) && base.IsHandleCreated) { System.Windows.Forms.NativeMethods.POINT pt = new System.Windows.Forms.NativeMethods.POINT(e.X, e.Y); System.Windows.Forms.UnsafeNativeMethods.MapWindowPoints(new HandleRef(child, child.Handle), new HandleRef(this, base.Handle), pt, 1); return new MouseEventArgs(e.Button, e.Clicks, pt.x, pt.y, e.Delta); } return e; }
internal Point GetItemPosition(int index) { System.Windows.Forms.NativeMethods.POINT lParam = new System.Windows.Forms.NativeMethods.POINT(); System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, base.Handle), 0x1010, index, lParam); return new Point(lParam.x, lParam.y); }
private bool ShouldForwardChildMouseMessage(Control child, MouseEventArgs me, ref Point pt) { Size size = child.Size; if ((me.Y > 1) && ((size.Height - me.Y) > 1)) { return false; } System.Windows.Forms.NativeMethods.POINT point = new System.Windows.Forms.NativeMethods.POINT { x = me.X, y = me.Y }; System.Windows.Forms.UnsafeNativeMethods.MapWindowPoints(new HandleRef(child, child.Handle), new HandleRef(this, base.Handle), point, 1); pt.X = point.x; pt.Y = point.y; return true; }
public static Point TranslatePoint(Point point, Control fromControl, Control toControl) { System.Windows.Forms.NativeMethods.POINT pt = new System.Windows.Forms.NativeMethods.POINT(point.X, point.Y); System.Windows.Forms.UnsafeNativeMethods.MapWindowPoints(new HandleRef(fromControl, fromControl.Handle), new HandleRef(toControl, toControl.Handle), pt, 1); return(new Point(pt.x, pt.y)); }
public override Point GetPositionFromCharIndex(int index) { if (richEditMajorVersion == 2) { return base.GetPositionFromCharIndex(index); } if ((index < 0) || (index > this.Text.Length)) { return Point.Empty; } System.Windows.Forms.NativeMethods.POINT wParam = new System.Windows.Forms.NativeMethods.POINT(); System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, base.Handle), 0xd6, wParam, index); return new Point(wParam.x, wParam.y); }
public override int GetCharIndexFromPosition(Point pt) { System.Windows.Forms.NativeMethods.POINT lParam = new System.Windows.Forms.NativeMethods.POINT(pt.X, pt.Y); int num = (int) System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, base.Handle), 0xd7, 0, lParam); string text = this.Text; if (num >= text.Length) { num = Math.Max(text.Length - 1, 0); } return num; }
public static extern bool SetWindowOrgEx(HandleRef hDC, int x, int y, [In, Out] System.Windows.Forms.NativeMethods.POINT point);
private void ShowContextMenu(TreeNode treeNode) { if ((treeNode.ContextMenu != null) || (treeNode.ContextMenuStrip != null)) { ContextMenu contextMenu = treeNode.ContextMenu; ContextMenuStrip contextMenuStrip = treeNode.ContextMenuStrip; if (contextMenu != null) { System.Windows.Forms.NativeMethods.POINT pt = new System.Windows.Forms.NativeMethods.POINT(); System.Windows.Forms.UnsafeNativeMethods.GetCursorPos(pt); System.Windows.Forms.UnsafeNativeMethods.SetForegroundWindow(new HandleRef(this, base.Handle)); contextMenu.OnPopup(EventArgs.Empty); System.Windows.Forms.SafeNativeMethods.TrackPopupMenuEx(new HandleRef(contextMenu, contextMenu.Handle), 0x40, pt.x, pt.y, new HandleRef(this, base.Handle), null); System.Windows.Forms.UnsafeNativeMethods.PostMessage(new HandleRef(this, base.Handle), 0, IntPtr.Zero, IntPtr.Zero); } else if (contextMenuStrip != null) { System.Windows.Forms.UnsafeNativeMethods.PostMessage(new HandleRef(this, base.Handle), 0x110b, 8, treeNode.Handle); contextMenuStrip.ShowInternal(this, base.PointToClient(Control.MousePosition), false); contextMenuStrip.Closing += new ToolStripDropDownClosingEventHandler(this.ContextMenuStripClosing); } } }
private void ProcessMouseButtonPressed(IntPtr hwndMouseMessageIsFrom, int x, int y) { int count = this._inputFilterQueue.Count; for (int i = 0; i < count; i++) { ToolStrip activeToolStripInternal = this.GetActiveToolStripInternal(); if (activeToolStripInternal == null) { break; } System.Windows.Forms.NativeMethods.POINT pt = new System.Windows.Forms.NativeMethods.POINT { x = x, y = y }; System.Windows.Forms.UnsafeNativeMethods.MapWindowPoints(new HandleRef(activeToolStripInternal, hwndMouseMessageIsFrom), new HandleRef(activeToolStripInternal, activeToolStripInternal.Handle), pt, 1); if (activeToolStripInternal.ClientRectangle.Contains(pt.x, pt.y)) { break; } ToolStripDropDown activeToolStripDropDown = activeToolStripInternal as ToolStripDropDown; if (activeToolStripDropDown != null) { if (((activeToolStripDropDown.OwnerToolStrip == null) || (activeToolStripDropDown.OwnerToolStrip.Handle != hwndMouseMessageIsFrom)) || ((activeToolStripDropDown.OwnerDropDownItem == null) || !activeToolStripDropDown.OwnerDropDownItem.DropDownButtonArea.Contains(x, y))) { CloseActiveDropDown(activeToolStripDropDown, ToolStripDropDownCloseReason.AppClicked); } } else { activeToolStripInternal.NotifySelectionChange(null); this.ExitMenuModeCore(); } } }
protected override void OnVisibleChanged(EventArgs e) { this.UpdateRenderSizeGrip(); Form mdiParentInternal = this.MdiParentInternal; if (mdiParentInternal != null) { mdiParentInternal.UpdateMdiWindowListStrip(); } base.OnVisibleChanged(e); bool flag = false; if (((base.IsHandleCreated && base.Visible) && ((this.AcceptButton != null) && System.Windows.Forms.UnsafeNativeMethods.SystemParametersInfo(0x5f, 0, ref flag, 0))) && flag) { Control acceptButton = this.AcceptButton as Control; System.Windows.Forms.NativeMethods.POINT pt = new System.Windows.Forms.NativeMethods.POINT(acceptButton.Left + (acceptButton.Width / 2), acceptButton.Top + (acceptButton.Height / 2)); System.Windows.Forms.UnsafeNativeMethods.ClientToScreen(new HandleRef(this, base.Handle), pt); if (!acceptButton.IsWindowObscured) { System.Windows.Forms.IntSecurity.AdjustCursorPosition.Assert(); try { Cursor.Position = new Point(pt.x, pt.y); } finally { CodeAccessPermission.RevertAssert(); } } } }
internal void SetItemPosition(int index, int x, int y) { if (!this.VirtualMode) { if ((index < 0) || (index >= this.itemCount)) { throw new ArgumentOutOfRangeException("index", System.Windows.Forms.SR.GetString("InvalidArgument", new object[] { "index", index.ToString(CultureInfo.CurrentCulture) })); } System.Windows.Forms.NativeMethods.POINT lParam = new System.Windows.Forms.NativeMethods.POINT { x = x, y = y }; System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, base.Handle), 0x1031, index, lParam); } }
public Point GetPoint(PointProperty prop) { if (!System.Windows.Forms.ClientUtils.IsEnumValid(prop, (int) prop, 0xd49, 0xd50)) { throw new InvalidEnumArgumentException("prop", (int) prop, typeof(PointProperty)); } System.Windows.Forms.NativeMethods.POINT pPoint = new System.Windows.Forms.NativeMethods.POINT(); this.lastHResult = System.Windows.Forms.SafeNativeMethods.GetThemePosition(new HandleRef(this, this.Handle), this.part, this.state, (int) prop, pPoint); return new Point(pPoint.x, pPoint.y); }
internal Rectangle AccessibilityGetGridEntryBounds(GridEntry gridEntry) { int rowFromGridEntry = this.GetRowFromGridEntry(gridEntry); if (rowFromGridEntry == -1) { return new Rectangle(0, 0, 0, 0); } Rectangle rectangle = this.GetRectangle(rowFromGridEntry, 3); System.Windows.Forms.NativeMethods.POINT pt = new System.Windows.Forms.NativeMethods.POINT(rectangle.X, rectangle.Y); System.Windows.Forms.UnsafeNativeMethods.ClientToScreen(new HandleRef(this, base.Handle), pt); return new Rectangle(pt.x, pt.y, rectangle.Width, rectangle.Height); }
int System.Windows.Forms.UnsafeNativeMethods.IDocHostUIHandler.ShowContextMenu(int dwID, System.Windows.Forms.NativeMethods.POINT pt, object pcmdtReserved, object pdispReserved) { WebBrowser host = (WebBrowser)base.Host; if (host.IsWebBrowserContextMenuEnabled) { return(1); } if ((pt.x == 0) && (pt.y == 0)) { pt.x = -1; pt.y = -1; } host.ShowContextMenu(pt.x, pt.y); return(0); }
private void WmNCHitTest(ref Message m) { if (this.formState[FormStateRenderSizeGrip] != 0) { int x = System.Windows.Forms.NativeMethods.Util.LOWORD(m.LParam); int y = System.Windows.Forms.NativeMethods.Util.HIWORD(m.LParam); System.Windows.Forms.NativeMethods.POINT pt = new System.Windows.Forms.NativeMethods.POINT(x, y); System.Windows.Forms.UnsafeNativeMethods.ScreenToClient(new HandleRef(this, base.Handle), pt); System.Drawing.Size clientSize = this.ClientSize; if (((pt.x >= (clientSize.Width - 0x10)) && (pt.y >= (clientSize.Height - 0x10))) && (clientSize.Height >= 0x10)) { m.Result = base.IsMirrored ? ((IntPtr) 0x10) : ((IntPtr) 0x11); return; } } base.WndProc(ref m); if (this.AutoSizeMode == System.Windows.Forms.AutoSizeMode.GrowAndShrink) { int result = (int) ((long) m.Result); if ((result >= 10) && (result <= 0x11)) { m.Result = (IntPtr) 0x12; } } }
public override AccessibleObject HitTest(int x, int y) { System.Windows.Forms.NativeMethods.POINT pt = new System.Windows.Forms.NativeMethods.POINT(x, y); System.Windows.Forms.UnsafeNativeMethods.ScreenToClient(new HandleRef(base.Owner, base.Owner.Handle), pt); Point point2 = ((PropertyGridView) base.Owner).FindPosition(pt.x, pt.y); if (point2 != PropertyGridView.InvalidPosition) { GridEntry gridEntryFromRow = ((PropertyGridView) base.Owner).GetGridEntryFromRow(point2.Y); if (gridEntryFromRow != null) { return gridEntryFromRow.AccessibilityObject; } } return null; }
protected internal override bool ProcessMnemonic(char charCode) { if (base.CanSelect) { try { System.Windows.Forms.NativeMethods.tagCONTROLINFO pCI = new System.Windows.Forms.NativeMethods.tagCONTROLINFO(); if (System.Windows.Forms.NativeMethods.Failed(this.GetOleControl().GetControlInfo(pCI))) { return false; } System.Windows.Forms.NativeMethods.MSG lpMsg = new System.Windows.Forms.NativeMethods.MSG { hwnd = (this.ContainingControl == null) ? IntPtr.Zero : this.ContainingControl.Handle, message = 260, wParam = (IntPtr) char.ToUpper(charCode, CultureInfo.CurrentCulture), lParam = (IntPtr) 0x20180001, time = System.Windows.Forms.SafeNativeMethods.GetTickCount() }; System.Windows.Forms.NativeMethods.POINT pt = new System.Windows.Forms.NativeMethods.POINT(); System.Windows.Forms.UnsafeNativeMethods.GetCursorPos(pt); lpMsg.pt_x = pt.x; lpMsg.pt_y = pt.y; if (System.Windows.Forms.SafeNativeMethods.IsAccelerator(new HandleRef(pCI, pCI.hAccel), pCI.cAccel, ref lpMsg, null)) { this.GetOleControl().OnMnemonic(ref lpMsg); base.Focus(); return true; } } catch (Exception) { return false; } } return false; }
public static Point TranslatePoint(Point point, Control fromControl, Control toControl) { System.Windows.Forms.NativeMethods.POINT pt = new System.Windows.Forms.NativeMethods.POINT(point.X, point.Y); System.Windows.Forms.UnsafeNativeMethods.MapWindowPoints(new HandleRef(fromControl, fromControl.Handle), new HandleRef(toControl, toControl.Handle), pt, 1); return new Point(pt.x, pt.y); }