private static Bitmap GetCheckBoxImage(Color checkColor, Rectangle fullSize, ref Color cacheCheckColor, ref Bitmap cacheCheckImage) { if (((cacheCheckImage == null) || !cacheCheckColor.Equals(checkColor)) || ((cacheCheckImage.Width != fullSize.Width) || (cacheCheckImage.Height != fullSize.Height))) { if (cacheCheckImage != null) { cacheCheckImage.Dispose(); cacheCheckImage = null; } System.Windows.Forms.NativeMethods.RECT rect = System.Windows.Forms.NativeMethods.RECT.FromXYWH(0, 0, fullSize.Width, fullSize.Height); Bitmap image = new Bitmap(fullSize.Width, fullSize.Height); Graphics wrapper = Graphics.FromImage(image); wrapper.Clear(Color.Transparent); IntPtr hdc = wrapper.GetHdc(); try { System.Windows.Forms.SafeNativeMethods.DrawFrameControl(new HandleRef(wrapper, hdc), ref rect, 2, 1); } finally { wrapper.ReleaseHdcInternal(hdc); wrapper.Dispose(); } image.MakeTransparent(); cacheCheckImage = image; cacheCheckColor = checkColor; } return(cacheCheckImage); }
internal static void MoveToScreenCenter(IntPtr hWnd) { System.Windows.Forms.NativeMethods.RECT rect = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.UnsafeNativeMethods.GetWindowRect(new HandleRef(null, hWnd), ref rect); Rectangle workingArea = Screen.GetWorkingArea(Control.MousePosition); int x = workingArea.X + (((workingArea.Width - rect.right) + rect.left) / 2); int y = workingArea.Y + (((workingArea.Height - rect.bottom) + rect.top) / 3); System.Windows.Forms.SafeNativeMethods.SetWindowPos(new HandleRef(null, hWnd), System.Windows.Forms.NativeMethods.NullHandleRef, x, y, 0, 0, 0x15); }
private void InvalidateItem(int index) { if (base.IsHandleCreated) { System.Windows.Forms.NativeMethods.RECT lparam = new System.Windows.Forms.NativeMethods.RECT(); base.SendMessage(0x198, index, ref lparam); System.Windows.Forms.SafeNativeMethods.InvalidateRect(new HandleRef(this, base.Handle), ref lparam, false); } }
private void DrawTreeItem(string itemText, int imageIndex, IntPtr dc, System.Windows.Forms.NativeMethods.RECT rcIn, int state, int backColor, int textColor) { IntNativeMethods.SIZE size = new IntNativeMethods.SIZE(); IntNativeMethods.RECT lpRect = new IntNativeMethods.RECT(); IntNativeMethods.RECT rect = new IntNativeMethods.RECT(rcIn.left, rcIn.top, rcIn.right, rcIn.bottom); ImageList imageList = base.ImageList; IntPtr zero = IntPtr.Zero; if ((state & 2) != 0) { zero = System.Windows.Forms.SafeNativeMethods.SelectObject(new HandleRef(null, dc), new HandleRef(base.Parent, base.Parent.FontHandle)); } if (((state & 1) != 0) && (this.hbrushDither != IntPtr.Zero)) { this.FillRectDither(dc, rcIn); System.Windows.Forms.SafeNativeMethods.SetBkMode(new HandleRef(null, dc), 1); } else { System.Windows.Forms.SafeNativeMethods.SetBkColor(new HandleRef(null, dc), backColor); IntUnsafeNativeMethods.ExtTextOut(new HandleRef(null, dc), 0, 0, 6, ref rect, null, 0, null); } IntUnsafeNativeMethods.GetTextExtentPoint32(new HandleRef(null, dc), itemText, size); lpRect.left = (rect.left + 0x10) + 8; lpRect.top = rect.top + (((rect.bottom - rect.top) - size.cy) >> 1); lpRect.bottom = lpRect.top + size.cy; lpRect.right = rect.right; System.Windows.Forms.SafeNativeMethods.SetTextColor(new HandleRef(null, dc), textColor); IntUnsafeNativeMethods.DrawText(new HandleRef(null, dc), itemText, ref lpRect, 0x8804); System.Windows.Forms.SafeNativeMethods.ImageList_Draw(new HandleRef(imageList, imageList.Handle), imageIndex, new HandleRef(null, dc), 4, rect.top + (((rect.bottom - rect.top) - 0x10) >> 1), 1); if ((state & 2) != 0) { int clr = System.Windows.Forms.SafeNativeMethods.SetBkColor(new HandleRef(null, dc), ColorTranslator.ToWin32(SystemColors.ControlLightLight)); lpRect.left = rect.left; lpRect.top = rect.top; lpRect.bottom = rect.top + 1; lpRect.right = rect.right; IntUnsafeNativeMethods.ExtTextOut(new HandleRef(null, dc), 0, 0, 2, ref lpRect, null, 0, null); lpRect.bottom = rect.bottom; lpRect.right = rect.left + 1; IntUnsafeNativeMethods.ExtTextOut(new HandleRef(null, dc), 0, 0, 2, ref lpRect, null, 0, null); System.Windows.Forms.SafeNativeMethods.SetBkColor(new HandleRef(null, dc), ColorTranslator.ToWin32(SystemColors.ControlDark)); lpRect.left = rect.left; lpRect.right = rect.right; lpRect.top = rect.bottom - 1; lpRect.bottom = rect.bottom; IntUnsafeNativeMethods.ExtTextOut(new HandleRef(null, dc), 0, 0, 2, ref lpRect, null, 0, null); lpRect.left = rect.right - 1; lpRect.top = rect.top; IntUnsafeNativeMethods.ExtTextOut(new HandleRef(null, dc), 0, 0, 2, ref lpRect, null, 0, null); System.Windows.Forms.SafeNativeMethods.SetBkColor(new HandleRef(null, dc), clr); } if (zero != IntPtr.Zero) { System.Windows.Forms.SafeNativeMethods.SelectObject(new HandleRef(null, dc), new HandleRef(null, zero)); } }
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); } } }
private void FillRectDither(IntPtr dc, System.Windows.Forms.NativeMethods.RECT rc) { if (System.Windows.Forms.SafeNativeMethods.SelectObject(new HandleRef(null, dc), new HandleRef(this, this.hbrushDither)) != IntPtr.Zero) { int crColor = System.Windows.Forms.SafeNativeMethods.SetTextColor(new HandleRef(null, dc), ColorTranslator.ToWin32(SystemColors.ControlLightLight)); int clr = System.Windows.Forms.SafeNativeMethods.SetBkColor(new HandleRef(null, dc), ColorTranslator.ToWin32(SystemColors.Control)); System.Windows.Forms.SafeNativeMethods.PatBlt(new HandleRef(null, dc), rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, 0xf00021); System.Windows.Forms.SafeNativeMethods.SetTextColor(new HandleRef(null, dc), crColor); System.Windows.Forms.SafeNativeMethods.SetBkColor(new HandleRef(null, dc), clr); } }
private void WmEraseBkgnd(ref Message m) { System.Windows.Forms.NativeMethods.RECT rect = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.SafeNativeMethods.GetClientRect(new HandleRef(this, base.Handle), ref rect); using (Graphics graphics = Graphics.FromHdcInternal(m.WParam)) { using (Brush brush = new SolidBrush(this.BackColor)) { graphics.FillRectangle(brush, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); } } m.Result = (IntPtr)1; }
protected void SetDisplayRectLocation(int x, int y) { int nXAmount = 0; int nYAmount = 0; Rectangle clientRectangle = base.ClientRectangle; Rectangle displayRect = this.displayRect; int num3 = Math.Min(clientRectangle.Width - displayRect.Width, 0); int num4 = Math.Min(clientRectangle.Height - displayRect.Height, 0); if (x > 0) { x = 0; } if (y > 0) { y = 0; } if (x < num3) { x = num3; } if (y < num4) { y = num4; } if (displayRect.X != x) { nXAmount = x - displayRect.X; } if (displayRect.Y != y) { nYAmount = y - displayRect.Y; } this.displayRect.X = x; this.displayRect.Y = y; if ((nXAmount != 0) || ((nYAmount != 0) && base.IsHandleCreated)) { Rectangle rectangle3 = base.ClientRectangle; System.Windows.Forms.NativeMethods.RECT rectClip = System.Windows.Forms.NativeMethods.RECT.FromXYWH(rectangle3.X, rectangle3.Y, rectangle3.Width, rectangle3.Height); System.Windows.Forms.NativeMethods.RECT prcUpdate = System.Windows.Forms.NativeMethods.RECT.FromXYWH(rectangle3.X, rectangle3.Y, rectangle3.Width, rectangle3.Height); System.Windows.Forms.SafeNativeMethods.ScrollWindowEx(new HandleRef(this, base.Handle), nXAmount, nYAmount, null, ref rectClip, System.Windows.Forms.NativeMethods.NullHandleRef, ref prcUpdate, 7); } for (int i = 0; i < base.Controls.Count; i++) { Control control = base.Controls[i]; if ((control != null) && control.IsHandleCreated) { control.UpdateBounds(); } } }
private void SetWindowRgn() { IntPtr zero = IntPtr.Zero; IntPtr handle = IntPtr.Zero; System.Windows.Forms.NativeMethods.RECT lpRect = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.CreateParams createParams = this.CreateParams; System.Windows.Forms.SafeNativeMethods.AdjustWindowRectEx(ref lpRect, createParams.Style, false, createParams.ExStyle); Rectangle bounds = base.Bounds; zero = System.Windows.Forms.SafeNativeMethods.CreateRectRgn(0, 0, bounds.Width, bounds.Height); try { handle = System.Windows.Forms.SafeNativeMethods.CreateRectRgn(-lpRect.left, -lpRect.top, bounds.Width - lpRect.right, bounds.Height - lpRect.bottom); try { if ((zero == IntPtr.Zero) || (handle == IntPtr.Zero)) { throw new InvalidOperationException(System.Windows.Forms.SR.GetString("ErrorSettingWindowRegion")); } if (System.Windows.Forms.SafeNativeMethods.CombineRgn(new HandleRef(null, zero), new HandleRef(null, zero), new HandleRef(null, handle), 4) == 0) { throw new InvalidOperationException(System.Windows.Forms.SR.GetString("ErrorSettingWindowRegion")); } if (System.Windows.Forms.UnsafeNativeMethods.SetWindowRgn(new HandleRef(this, base.Handle), new HandleRef(null, zero), true) == 0) { throw new InvalidOperationException(System.Windows.Forms.SR.GetString("ErrorSettingWindowRegion")); } zero = IntPtr.Zero; } finally { if (handle != IntPtr.Zero) { System.Windows.Forms.SafeNativeMethods.DeleteObject(new HandleRef(null, handle)); } } } finally { if (zero != IntPtr.Zero) { System.Windows.Forms.SafeNativeMethods.DeleteObject(new HandleRef(null, zero)); } } }
private void InvalidateNonClient() { if (this.IsPopupTextBox) { System.Windows.Forms.NativeMethods.RECT absoluteClientRECT = this.AbsoluteClientRECT; HandleRef nullHandleRef = System.Windows.Forms.NativeMethods.NullHandleRef; HandleRef ref3 = System.Windows.Forms.NativeMethods.NullHandleRef; HandleRef ref4 = System.Windows.Forms.NativeMethods.NullHandleRef; try { ref4 = new HandleRef(this, System.Windows.Forms.SafeNativeMethods.CreateRectRgn(0, 0, base.Width, base.Height)); ref3 = new HandleRef(this, System.Windows.Forms.SafeNativeMethods.CreateRectRgn(absoluteClientRECT.left, absoluteClientRECT.top, absoluteClientRECT.right, absoluteClientRECT.bottom)); nullHandleRef = new HandleRef(this, System.Windows.Forms.SafeNativeMethods.CreateRectRgn(0, 0, 0, 0)); System.Windows.Forms.SafeNativeMethods.CombineRgn(nullHandleRef, ref4, ref3, 3); System.Windows.Forms.NativeMethods.RECT rcUpdate = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.SafeNativeMethods.RedrawWindow(new HandleRef(this, base.Handle), ref rcUpdate, nullHandleRef, 0x705); } finally { try { if (nullHandleRef.Handle != IntPtr.Zero) { System.Windows.Forms.SafeNativeMethods.DeleteObject(nullHandleRef); } } finally { try { if (ref3.Handle != IntPtr.Zero) { System.Windows.Forms.SafeNativeMethods.DeleteObject(ref3); } } finally { if (ref4.Handle != IntPtr.Zero) { System.Windows.Forms.SafeNativeMethods.DeleteObject(ref4); } } } } } }
private void SetPositionNoInvalidate(Point value) { Point position = this.position; this.position = value; this.position.X = Math.Min(this.position.X, this.virtualSize.Width - base.Width); this.position.Y = Math.Min(this.position.Y, this.virtualSize.Height - base.Height); if (this.position.X < 0) { this.position.X = 0; } if (this.position.Y < 0) { this.position.Y = 0; } Rectangle clientRectangle = base.ClientRectangle; System.Windows.Forms.NativeMethods.RECT rectScrollRegion = System.Windows.Forms.NativeMethods.RECT.FromXYWH(clientRectangle.X, clientRectangle.Y, clientRectangle.Width, clientRectangle.Height); System.Windows.Forms.SafeNativeMethods.ScrollWindow(new HandleRef(this, base.Handle), position.X - this.position.X, position.Y - this.position.Y, ref rectScrollRegion, ref rectScrollRegion); System.Windows.Forms.UnsafeNativeMethods.SetScrollPos(new HandleRef(this, base.Handle), 0, this.position.X, true); System.Windows.Forms.UnsafeNativeMethods.SetScrollPos(new HandleRef(this, base.Handle), 1, this.position.Y, true); }
private void PaintThemedButtonBackground(PaintEventArgs e, Rectangle bounds, bool up) { PushButtonState state = this.DetermineState(up); if (ButtonRenderer.IsBackgroundPartiallyTransparent(state)) { ButtonRenderer.DrawParentBackground(e.Graphics, bounds, base.Control); } ButtonRenderer.DrawButton(e.Graphics, base.Control.ClientRectangle, false, state); bounds.Inflate(-ButtonBaseAdapter.buttonBorderSize, -ButtonBaseAdapter.buttonBorderSize); if (!base.Control.UseVisualStyleBackColor) { bool flag = false; Color backColor = base.Control.BackColor; if (((backColor.A == 0xff) && (e.HDC != IntPtr.Zero)) && (DisplayInformation.BitsPerPixel > 8)) { System.Windows.Forms.NativeMethods.RECT rect = new System.Windows.Forms.NativeMethods.RECT(bounds.X, bounds.Y, bounds.Right, bounds.Bottom); System.Windows.Forms.SafeNativeMethods.FillRect(new HandleRef(e, e.HDC), ref rect, new HandleRef(this, base.Control.BackColorBrush)); flag = true; } if (!flag && (backColor.A > 0)) { if (backColor.A == 0xff) { backColor = e.Graphics.GetNearestColor(backColor); } using (Brush brush = new SolidBrush(backColor)) { e.Graphics.FillRectangle(brush, bounds); } } } if ((base.Control.BackgroundImage != null) && !DisplayInformation.HighContrast) { ControlPaint.DrawBackgroundImage(e.Graphics, base.Control.BackgroundImage, Color.Transparent, base.Control.BackgroundImageLayout, base.Control.ClientRectangle, bounds, base.Control.DisplayRectangle.Location, base.Control.RightToLeft); } }
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 ValidateRect(HandleRef hWnd, [In, Out] ref System.Windows.Forms.NativeMethods.RECT rect);
protected override void WndProc(ref Message m) { switch (m.Msg) { case 7: try { this.fireSetFocus = false; base.WndProc(ref m); return; } finally { this.fireSetFocus = true; } break; case 8: break; case 15: if (!base.GetStyle(ControlStyles.UserPaint) && ((this.FlatStyle == System.Windows.Forms.FlatStyle.Flat) || (this.FlatStyle == System.Windows.Forms.FlatStyle.Popup))) { using (WindowsRegion region = new WindowsRegion(this.FlatComboBoxAdapter.dropDownRect)) { using (WindowsRegion region2 = new WindowsRegion(base.Bounds)) { IntPtr wParam; System.Windows.Forms.NativeMethods.RegionFlags flags = (System.Windows.Forms.NativeMethods.RegionFlags) System.Windows.Forms.SafeNativeMethods.GetUpdateRgn(new HandleRef(this, base.Handle), new HandleRef(this, region2.HRegion), true); region.CombineRegion(region2, region, RegionCombineMode.DIFF); Rectangle updateRegionBox = region2.ToRectangle(); this.FlatComboBoxAdapter.ValidateOwnerDrawRegions(this, updateRegionBox); System.Windows.Forms.NativeMethods.PAINTSTRUCT lpPaint = new System.Windows.Forms.NativeMethods.PAINTSTRUCT(); bool flag2 = false; if (m.WParam == IntPtr.Zero) { wParam = System.Windows.Forms.UnsafeNativeMethods.BeginPaint(new HandleRef(this, base.Handle), ref lpPaint); flag2 = true; } else { wParam = m.WParam; } using (DeviceContext context = DeviceContext.FromHdc(wParam)) { using (WindowsGraphics graphics = new WindowsGraphics(context)) { if (flags != System.Windows.Forms.NativeMethods.RegionFlags.ERROR) { graphics.DeviceContext.SetClip(region); } m.WParam = wParam; this.DefWndProc(ref m); if (flags != System.Windows.Forms.NativeMethods.RegionFlags.ERROR) { graphics.DeviceContext.SetClip(region2); } using (Graphics graphics2 = Graphics.FromHdcInternal(wParam)) { this.FlatComboBoxAdapter.DrawFlatCombo(this, graphics2); } } } if (flag2) { System.Windows.Forms.UnsafeNativeMethods.EndPaint(new HandleRef(this, base.Handle), ref lpPaint); } } return; } } base.WndProc(ref m); return; case 20: this.WmEraseBkgnd(ref m); return; case 0x47: if (!this.suppressNextWindosPos) { base.WndProc(ref m); } this.suppressNextWindosPos = false; return; case 130: base.WndProc(ref m); this.ReleaseChildWindow(); return; case 0x20: base.WndProc(ref m); return; case 0x30: if (base.Width == 0) { this.suppressNextWindosPos = true; } base.WndProc(ref m); return; case 0x133: case 0x134: goto Label_017F; case 0x201: this.mouseEvents = true; base.WndProc(ref m); return; case 0x202: { System.Windows.Forms.NativeMethods.RECT rect = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.UnsafeNativeMethods.GetWindowRect(new HandleRef(this, base.Handle), ref rect); Rectangle rectangle = new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); int x = System.Windows.Forms.NativeMethods.Util.SignedLOWORD(m.LParam); int y = System.Windows.Forms.NativeMethods.Util.SignedHIWORD(m.LParam); Point p = new Point(x, y); p = base.PointToScreen(p); if (this.mouseEvents && !base.ValidationCancelled) { this.mouseEvents = false; if (base.Capture && rectangle.Contains(p)) { this.OnClick(new MouseEventArgs(MouseButtons.Left, 1, System.Windows.Forms.NativeMethods.Util.SignedLOWORD(m.LParam), System.Windows.Forms.NativeMethods.Util.SignedHIWORD(m.LParam), 0)); this.OnMouseClick(new MouseEventArgs(MouseButtons.Left, 1, System.Windows.Forms.NativeMethods.Util.SignedLOWORD(m.LParam), System.Windows.Forms.NativeMethods.Util.SignedHIWORD(m.LParam), 0)); } base.WndProc(ref m); return; } base.CaptureInternal = false; this.DefWndProc(ref m); return; } case 0x210: this.WmParentNotify(ref m); return; case 0x202b: this.WmReflectDrawItem(ref m); return; case 0x202c: this.WmReflectMeasureItem(ref m); return; case 0x2111: this.WmReflectCommand(ref m); return; case 0x2a3: this.DefWndProc(ref m); this.OnMouseLeaveInternal(EventArgs.Empty); return; case 0x318: if ((base.GetStyle(ControlStyles.UserPaint) || (this.FlatStyle != System.Windows.Forms.FlatStyle.Flat)) && (this.FlatStyle != System.Windows.Forms.FlatStyle.Popup)) { goto Label_04EF; } this.DefWndProc(ref m); if ((((int) ((long) m.LParam)) & 4) != 4) { goto Label_04EF; } if ((!base.GetStyle(ControlStyles.UserPaint) && (this.FlatStyle == System.Windows.Forms.FlatStyle.Flat)) || (this.FlatStyle == System.Windows.Forms.FlatStyle.Popup)) { using (Graphics graphics3 = Graphics.FromHdcInternal(m.WParam)) { this.FlatComboBoxAdapter.DrawFlatCombo(this, graphics3); } } return; default: if (m.Msg == System.Windows.Forms.NativeMethods.WM_MOUSEENTER) { this.DefWndProc(ref m); this.OnMouseEnterInternal(EventArgs.Empty); return; } base.WndProc(ref m); return; } try { this.fireLostFocus = false; base.WndProc(ref m); if (((!Application.RenderWithVisualStyles && !base.GetStyle(ControlStyles.UserPaint)) && (this.DropDownStyle == ComboBoxStyle.DropDownList)) && ((this.FlatStyle == System.Windows.Forms.FlatStyle.Flat) || (this.FlatStyle == System.Windows.Forms.FlatStyle.Popup))) { System.Windows.Forms.UnsafeNativeMethods.PostMessage(new HandleRef(this, base.Handle), 0x2a3, 0, 0); } return; } finally { this.fireLostFocus = true; } Label_017F: m.Result = this.InitializeDCForWmCtlColor(m.WParam, m.Msg); return; Label_04EF: base.WndProc(ref m); }
public static extern bool AdjustWindowRectEx(ref System.Windows.Forms.NativeMethods.RECT lpRect, int dwStyle, bool bMenu, int dwExStyle);
public static extern int FillRect(HandleRef hdc, [In] ref System.Windows.Forms.NativeMethods.RECT rect, HandleRef hbrush);
private void WmEraseBkgnd(ref Message m) { System.Windows.Forms.NativeMethods.RECT rect = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.SafeNativeMethods.GetClientRect(new HandleRef(this, base.Handle), ref rect); using (Graphics graphics = Graphics.FromHdcInternal(m.WParam)) { using (Brush brush = new SolidBrush(this.BackColor)) { graphics.FillRectangle(brush, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); } } m.Result = (IntPtr) 1; }
private System.Drawing.Size ComputeWindowSize(System.Drawing.Size clientSize, int style, int exStyle) { System.Windows.Forms.NativeMethods.RECT lpRect = new System.Windows.Forms.NativeMethods.RECT(0, 0, clientSize.Width, clientSize.Height); System.Windows.Forms.SafeNativeMethods.AdjustWindowRectEx(ref lpRect, style, this.HasMenu, exStyle); return new System.Drawing.Size(lpRect.right - lpRect.left, lpRect.bottom - lpRect.top); }
private void WmNotifyDropDown(ref Message m) { System.Windows.Forms.NativeMethods.NMTOOLBAR lParam = (System.Windows.Forms.NativeMethods.NMTOOLBAR) m.GetLParam(typeof(System.Windows.Forms.NativeMethods.NMTOOLBAR)); ToolBarButton button = this.buttons[lParam.iItem]; if (button == null) { throw new InvalidOperationException(System.Windows.Forms.SR.GetString("ToolBarButtonNotFound")); } this.OnButtonDropDown(new ToolBarButtonClickEventArgs(button)); Menu dropDownMenu = button.DropDownMenu; if (dropDownMenu != null) { System.Windows.Forms.NativeMethods.RECT lparam = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.NativeMethods.TPMPARAMS tpm = new System.Windows.Forms.NativeMethods.TPMPARAMS(); base.SendMessage(0x433, lParam.iItem, ref lparam); if (dropDownMenu.GetType().IsAssignableFrom(typeof(ContextMenu))) { ((ContextMenu) dropDownMenu).Show(this, new Point(lparam.left, lparam.bottom)); } else { Menu mainMenu = dropDownMenu.GetMainMenu(); if (mainMenu != null) { mainMenu.ProcessInitMenuPopup(dropDownMenu.Handle); } System.Windows.Forms.UnsafeNativeMethods.MapWindowPoints(new HandleRef(lParam.hdr, lParam.hdr.hwndFrom), System.Windows.Forms.NativeMethods.NullHandleRef, ref lparam, 2); tpm.rcExclude_left = lparam.left; tpm.rcExclude_top = lparam.top; tpm.rcExclude_right = lparam.right; tpm.rcExclude_bottom = lparam.bottom; System.Windows.Forms.SafeNativeMethods.TrackPopupMenuEx(new HandleRef(dropDownMenu, dropDownMenu.Handle), 0x40, lparam.left, lparam.bottom, new HandleRef(this, base.Handle), tpm); } } }
private void OnMouseLeaveInternal(EventArgs args) { System.Windows.Forms.NativeMethods.RECT rect = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.UnsafeNativeMethods.GetWindowRect(new HandleRef(this, base.Handle), ref rect); Rectangle rectangle = new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); Point mousePosition = Control.MousePosition; if (!rectangle.Contains(mousePosition)) { this.OnMouseLeave(args); this.mouseInEdit = false; } }
internal Point EditToComboboxMapping(Message m) { if (this.childEdit == null) { return new Point(0, 0); } System.Windows.Forms.NativeMethods.RECT rect = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.UnsafeNativeMethods.GetWindowRect(new HandleRef(this, base.Handle), ref rect); System.Windows.Forms.NativeMethods.RECT rect2 = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.UnsafeNativeMethods.GetWindowRect(new HandleRef(this, this.childEdit.Handle), ref rect2); int x = System.Windows.Forms.NativeMethods.Util.SignedLOWORD(m.LParam) + (rect2.left - rect.left); return new Point(x, System.Windows.Forms.NativeMethods.Util.SignedHIWORD(m.LParam) + (rect2.top - rect.top)); }
public void ValidateOwnerDrawRegions(ComboBox comboBox, Rectangle updateRegionBox) { if (comboBox == null) { System.Windows.Forms.NativeMethods.RECT rect; Rectangle r = new Rectangle(0, 0, comboBox.Width, this.innerBorder.Top); Rectangle rectangle2 = new Rectangle(0, this.innerBorder.Bottom, comboBox.Width, comboBox.Height - this.innerBorder.Bottom); Rectangle rectangle3 = new Rectangle(0, 0, this.innerBorder.Left, comboBox.Height); Rectangle rectangle4 = new Rectangle(this.innerBorder.Right, 0, comboBox.Width - this.innerBorder.Right, comboBox.Height); if (r.IntersectsWith(updateRegionBox)) { rect = new System.Windows.Forms.NativeMethods.RECT(r); System.Windows.Forms.SafeNativeMethods.ValidateRect(new HandleRef(comboBox, comboBox.Handle), ref rect); } if (rectangle2.IntersectsWith(updateRegionBox)) { rect = new System.Windows.Forms.NativeMethods.RECT(rectangle2); System.Windows.Forms.SafeNativeMethods.ValidateRect(new HandleRef(comboBox, comboBox.Handle), ref rect); } if (rectangle3.IntersectsWith(updateRegionBox)) { rect = new System.Windows.Forms.NativeMethods.RECT(rectangle3); System.Windows.Forms.SafeNativeMethods.ValidateRect(new HandleRef(comboBox, comboBox.Handle), ref rect); } if (rectangle4.IntersectsWith(updateRegionBox)) { rect = new System.Windows.Forms.NativeMethods.RECT(rectangle4); System.Windows.Forms.SafeNativeMethods.ValidateRect(new HandleRef(comboBox, comboBox.Handle), ref rect); } } }
private void ChildWndProc(ref Message m) { switch (m.Msg) { case 0x30: this.DefChildWndProc(ref m); if ((this.childEdit != null) && (m.HWnd == this.childEdit.Handle)) { System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, this.childEdit.Handle), 0xd3, 3, 0); } return; case 0x51: this.DefChildWndProc(ref m); return; case 7: if (!base.DesignMode) { ImeContext.SetImeStatus(base.CachedImeMode, m.HWnd); } if (!base.HostedInWin32DialogManager) { IContainerControl containerControlInternal = base.GetContainerControlInternal(); if (containerControlInternal != null) { ContainerControl control2 = containerControlInternal as ContainerControl; if ((control2 != null) && !control2.ActivateControlInternal(this, false)) { return; } } } this.DefChildWndProc(ref m); if (this.fireSetFocus) { this.OnGotFocus(EventArgs.Empty); } if (this.FlatStyle == System.Windows.Forms.FlatStyle.Popup) { base.Invalidate(); } return; case 8: if (!base.DesignMode) { base.OnImeContextStatusChanged(m.HWnd); } this.DefChildWndProc(ref m); if (this.fireLostFocus) { this.OnLostFocus(EventArgs.Empty); } if (this.FlatStyle == System.Windows.Forms.FlatStyle.Popup) { base.Invalidate(); } return; case 0x20: if (((this.Cursor != this.DefaultCursor) && (this.childEdit != null)) && ((m.HWnd == this.childEdit.Handle) && (System.Windows.Forms.NativeMethods.Util.LOWORD(m.LParam) == 1))) { Cursor.CurrentInternal = this.Cursor; return; } this.DefChildWndProc(ref m); return; case 0x100: case 260: if (this.SystemAutoCompleteEnabled && !ACNativeWindow.AutoCompleteActive) { this.finder.FindDropDowns(false); } if (this.AutoCompleteMode != System.Windows.Forms.AutoCompleteMode.None) { char wParam = (char) ((ushort) ((long) m.WParam)); if (wParam == '\x001b') { this.DroppedDown = false; } else if ((wParam == '\r') && this.DroppedDown) { this.UpdateText(); this.OnSelectionChangeCommittedInternal(EventArgs.Empty); this.DroppedDown = false; } } if ((this.DropDownStyle == ComboBoxStyle.Simple) && (m.HWnd == this.childListBox.Handle)) { this.DefChildWndProc(ref m); return; } if ((base.PreProcessControlMessage(ref m) != PreProcessControlState.MessageProcessed) && !this.ProcessKeyMessage(ref m)) { this.DefChildWndProc(ref m); } return; case 0x101: case 0x105: if ((this.DropDownStyle != ComboBoxStyle.Simple) || !(m.HWnd == this.childListBox.Handle)) { if (base.PreProcessControlMessage(ref m) != PreProcessControlState.MessageProcessed) { if (this.ProcessKeyMessage(ref m)) { return; } this.DefChildWndProc(ref m); } break; } this.DefChildWndProc(ref m); break; case 0x102: if ((this.DropDownStyle != ComboBoxStyle.Simple) || !(m.HWnd == this.childListBox.Handle)) { if ((base.PreProcessControlMessage(ref m) != PreProcessControlState.MessageProcessed) && !this.ProcessKeyMessage(ref m)) { this.DefChildWndProc(ref m); } return; } this.DefChildWndProc(ref m); return; case 0x106: if ((this.DropDownStyle != ComboBoxStyle.Simple) || !(m.HWnd == this.childListBox.Handle)) { if ((base.PreProcessControlMessage(ref m) != PreProcessControlState.MessageProcessed) && !this.ProcessKeyEventArgs(ref m)) { this.DefChildWndProc(ref m); } return; } this.DefChildWndProc(ref m); return; case 0x7b: if ((this.ContextMenu != null) || (this.ContextMenuStrip != null)) { System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, base.Handle), 0x7b, m.WParam, m.LParam); return; } this.DefChildWndProc(ref m); return; case 0x200: { Point point9 = this.EditToComboboxMapping(m); this.DefChildWndProc(ref m); this.OnMouseEnterInternal(EventArgs.Empty); this.OnMouseMove(new MouseEventArgs(Control.MouseButtons, 0, point9.X, point9.Y, 0)); return; } case 0x201: { this.mousePressed = true; this.mouseEvents = true; base.CaptureInternal = true; this.DefChildWndProc(ref m); Point point4 = this.EditToComboboxMapping(m); this.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, point4.X, point4.Y, 0)); return; } case 0x202: { System.Windows.Forms.NativeMethods.RECT rect = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.UnsafeNativeMethods.GetWindowRect(new HandleRef(this, base.Handle), ref rect); Rectangle rectangle = new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); int x = System.Windows.Forms.NativeMethods.Util.SignedLOWORD(m.LParam); int y = System.Windows.Forms.NativeMethods.Util.SignedHIWORD(m.LParam); Point p = new Point(x, y); p = base.PointToScreen(p); if (this.mouseEvents && !base.ValidationCancelled) { this.mouseEvents = false; if (this.mousePressed) { if (!rectangle.Contains(p)) { this.mousePressed = false; this.mouseInEdit = false; this.OnMouseLeave(EventArgs.Empty); } else { this.mousePressed = false; this.OnClick(new MouseEventArgs(MouseButtons.Left, 1, System.Windows.Forms.NativeMethods.Util.SignedLOWORD(m.LParam), System.Windows.Forms.NativeMethods.Util.SignedHIWORD(m.LParam), 0)); this.OnMouseClick(new MouseEventArgs(MouseButtons.Left, 1, System.Windows.Forms.NativeMethods.Util.SignedLOWORD(m.LParam), System.Windows.Forms.NativeMethods.Util.SignedHIWORD(m.LParam), 0)); } } } this.DefChildWndProc(ref m); base.CaptureInternal = false; p = this.EditToComboboxMapping(m); this.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, p.X, p.Y, 0)); return; } case 0x203: { this.mousePressed = true; this.mouseEvents = true; base.CaptureInternal = true; this.DefChildWndProc(ref m); Point point = this.EditToComboboxMapping(m); this.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, point.X, point.Y, 0)); return; } case 0x204: { this.mousePressed = true; this.mouseEvents = true; if ((this.ContextMenu != null) || (this.ContextMenuStrip != null)) { base.CaptureInternal = true; } this.DefChildWndProc(ref m); Point point7 = this.EditToComboboxMapping(m); this.OnMouseDown(new MouseEventArgs(MouseButtons.Right, 1, point7.X, point7.Y, 0)); return; } case 0x205: { this.mousePressed = false; this.mouseEvents = false; if (this.ContextMenu != null) { base.CaptureInternal = false; } this.DefChildWndProc(ref m); Point point8 = this.EditToComboboxMapping(m); this.OnMouseUp(new MouseEventArgs(MouseButtons.Right, 1, point8.X, point8.Y, 0)); return; } case 0x206: { this.mousePressed = true; this.mouseEvents = true; base.CaptureInternal = true; this.DefChildWndProc(ref m); Point point3 = this.EditToComboboxMapping(m); this.OnMouseDown(new MouseEventArgs(MouseButtons.Right, 1, point3.X, point3.Y, 0)); return; } case 0x207: { this.mousePressed = true; this.mouseEvents = true; base.CaptureInternal = true; this.DefChildWndProc(ref m); Point point6 = this.EditToComboboxMapping(m); this.OnMouseDown(new MouseEventArgs(MouseButtons.Middle, 1, point6.X, point6.Y, 0)); return; } case 520: this.mousePressed = false; this.mouseEvents = false; base.CaptureInternal = false; this.DefChildWndProc(ref m); this.OnMouseUp(new MouseEventArgs(MouseButtons.Middle, 1, System.Windows.Forms.NativeMethods.Util.SignedLOWORD(m.LParam), System.Windows.Forms.NativeMethods.Util.SignedHIWORD(m.LParam), 0)); return; case 0x209: { this.mousePressed = true; this.mouseEvents = true; base.CaptureInternal = true; this.DefChildWndProc(ref m); Point point2 = this.EditToComboboxMapping(m); this.OnMouseDown(new MouseEventArgs(MouseButtons.Middle, 1, point2.X, point2.Y, 0)); return; } case 0x2a3: this.DefChildWndProc(ref m); this.OnMouseLeaveInternal(EventArgs.Empty); return; default: this.DefChildWndProc(ref m); return; } if (this.SystemAutoCompleteEnabled && !ACNativeWindow.AutoCompleteActive) { this.finder.FindDropDowns(); } }
internal Rectangle GetSubItemRect(int itemIndex, int subItemIndex, ItemBoundsPortion portion) { if (this.View != System.Windows.Forms.View.Details) { return Rectangle.Empty; } if ((itemIndex < 0) || (itemIndex >= this.Items.Count)) { throw new ArgumentOutOfRangeException("itemIndex", System.Windows.Forms.SR.GetString("InvalidArgument", new object[] { "itemIndex", itemIndex.ToString(CultureInfo.CurrentCulture) })); } int count = this.Items[itemIndex].SubItems.Count; if ((subItemIndex < 0) || (subItemIndex >= count)) { throw new ArgumentOutOfRangeException("subItemIndex", System.Windows.Forms.SR.GetString("InvalidArgument", new object[] { "subItemIndex", subItemIndex.ToString(CultureInfo.CurrentCulture) })); } if (!System.Windows.Forms.ClientUtils.IsEnumValid(portion, (int) portion, 0, 3)) { throw new InvalidEnumArgumentException("portion", (int) portion, typeof(ItemBoundsPortion)); } if (this.Columns.Count == 0) { return Rectangle.Empty; } System.Windows.Forms.NativeMethods.RECT lparam = new System.Windows.Forms.NativeMethods.RECT { left = (int) portion, top = subItemIndex }; if (((int) ((long) base.SendMessage(0x1038, itemIndex, ref lparam))) == 0) { throw new ArgumentException(System.Windows.Forms.SR.GetString("InvalidArgument", new object[] { "itemIndex", itemIndex.ToString(CultureInfo.CurrentCulture) })); } return Rectangle.FromLTRB(lparam.left, lparam.top, lparam.right, lparam.bottom); }
public static unsafe System.Windows.Forms.NativeMethods.RECT[] GetRectsFromRegion(IntPtr hRgn) { System.Windows.Forms.NativeMethods.RECT[] rectArray = null; IntPtr zero = IntPtr.Zero; try { int cb = GetRegionData(new HandleRef(null, hRgn), 0, IntPtr.Zero); if (cb == 0) { return rectArray; } zero = Marshal.AllocCoTaskMem(cb); if (GetRegionData(new HandleRef(null, hRgn), cb, zero) != cb) { return rectArray; } System.Windows.Forms.NativeMethods.RGNDATAHEADER* rgndataheaderPtr = (System.Windows.Forms.NativeMethods.RGNDATAHEADER*) zero; if (rgndataheaderPtr->iType != 1) { return rectArray; } rectArray = new System.Windows.Forms.NativeMethods.RECT[rgndataheaderPtr->nCount]; int cbSizeOfStruct = rgndataheaderPtr->cbSizeOfStruct; for (int i = 0; i < rgndataheaderPtr->nCount; i++) { rectArray[i] = (System.Windows.Forms.NativeMethods.RECT) (((void*) zero) + cbSizeOfStruct)[Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.RECT)) * i]; } } finally { if (zero != IntPtr.Zero) { Marshal.FreeCoTaskMem(zero); } } return rectArray; }
private void ApplyClientSize() { if ((this.formState[FormStateWindowState] == 0) && base.IsHandleCreated) { System.Drawing.Size clientSize = this.ClientSize; bool hScroll = base.HScroll; bool vScroll = base.VScroll; bool flag3 = false; if (this.formState[FormStateSetClientSize] != 0) { flag3 = true; this.formState[FormStateSetClientSize] = 0; } if (flag3) { if (hScroll) { clientSize.Height += SystemInformation.HorizontalScrollBarHeight; } if (vScroll) { clientSize.Width += SystemInformation.VerticalScrollBarWidth; } } IntPtr handle = base.Handle; System.Windows.Forms.NativeMethods.RECT rect = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.SafeNativeMethods.GetClientRect(new HandleRef(this, handle), ref rect); Rectangle rectangle = Rectangle.FromLTRB(rect.left, rect.top, rect.right, rect.bottom); Rectangle bounds = base.Bounds; if (clientSize.Width != rectangle.Width) { System.Drawing.Size size2 = this.ComputeWindowSize(clientSize); if (vScroll) { size2.Width += SystemInformation.VerticalScrollBarWidth; } if (hScroll) { size2.Height += SystemInformation.HorizontalScrollBarHeight; } bounds.Width = size2.Width; bounds.Height = size2.Height; base.Bounds = bounds; System.Windows.Forms.SafeNativeMethods.GetClientRect(new HandleRef(this, handle), ref rect); rectangle = Rectangle.FromLTRB(rect.left, rect.top, rect.right, rect.bottom); } if (clientSize.Height != rectangle.Height) { int num = clientSize.Height - rectangle.Height; bounds.Height += num; base.Bounds = bounds; } base.UpdateBounds(); } }
internal void Realize() { if (this.Created) { string text; string str2; int num = 0; if (this.text == null) { text = ""; } else { text = this.text; } HorizontalAlignment right = this.alignment; if (this.parent.RightToLeft == RightToLeft.Yes) { switch (right) { case HorizontalAlignment.Left: right = HorizontalAlignment.Right; break; case HorizontalAlignment.Right: right = HorizontalAlignment.Left; break; } } switch (right) { case HorizontalAlignment.Right: str2 = "\t\t" + text; break; case HorizontalAlignment.Center: str2 = "\t" + text; break; default: str2 = text; break; } switch (this.borderStyle) { case StatusBarPanelBorderStyle.None: num |= 0x100; break; case StatusBarPanelBorderStyle.Raised: num |= 0x200; break; } switch (this.style) { case StatusBarPanelStyle.OwnerDraw: num |= 0x1000; break; } int num2 = this.GetIndex() | num; if (this.parent.RightToLeft == RightToLeft.Yes) { num2 |= 0x400; } if (((int)System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this.parent, this.parent.Handle), System.Windows.Forms.NativeMethods.SB_SETTEXT, (IntPtr)num2, str2)) == 0) { throw new InvalidOperationException(System.Windows.Forms.SR.GetString("UnableToSetPanelText")); } if ((this.icon != null) && (this.style != StatusBarPanelStyle.OwnerDraw)) { this.parent.SendMessage(0x40f, (IntPtr)this.GetIndex(), this.icon.Handle); } else { this.parent.SendMessage(0x40f, (IntPtr)this.GetIndex(), IntPtr.Zero); } if (this.style == StatusBarPanelStyle.OwnerDraw) { System.Windows.Forms.NativeMethods.RECT lParam = new System.Windows.Forms.NativeMethods.RECT(); if (((int)System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this.parent, this.parent.Handle), 0x40a, (IntPtr)this.GetIndex(), ref lParam)) != 0) { this.parent.Invalidate(Rectangle.FromLTRB(lParam.left, lParam.top, lParam.right, lParam.bottom)); } } } }
public static extern bool InvalidateRect(HandleRef hWnd, ref System.Windows.Forms.NativeMethods.RECT rect, bool erase);
public static extern bool DrawFrameControl(HandleRef hDC, ref System.Windows.Forms.NativeMethods.RECT rect, int type, int state);
public static extern IntPtr MonitorFromRect(ref System.Windows.Forms.NativeMethods.RECT rect, int flags);
public static extern bool GetClipCursor([In, Out] ref System.Windows.Forms.NativeMethods.RECT lpRect);
public static extern bool ScrollWindow(HandleRef hWnd, int nXAmount, int nYAmount, ref System.Windows.Forms.NativeMethods.RECT rectScrollRegion, ref System.Windows.Forms.NativeMethods.RECT rectClip);
public static extern int GetRgnBox(HandleRef hRegion, ref System.Windows.Forms.NativeMethods.RECT clipRect);
private void WmEraseBkgnd(ref Message m) { if ((this.DropDownStyle == ComboBoxStyle.Simple) && (this.ParentInternal != null)) { System.Windows.Forms.NativeMethods.RECT rect = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.SafeNativeMethods.GetClientRect(new HandleRef(this, base.Handle), ref rect); Control parentInternal = this.ParentInternal; Graphics graphics = Graphics.FromHdcInternal(m.WParam); if (parentInternal != null) { Brush brush = new SolidBrush(parentInternal.BackColor); graphics.FillRectangle(brush, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); brush.Dispose(); } else { graphics.FillRectangle(SystemBrushes.Control, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); } graphics.Dispose(); m.Result = (IntPtr) 1; } else { base.WndProc(ref m); } }
public static extern bool LPtoDP(HandleRef hDC, [In, Out] ref System.Windows.Forms.NativeMethods.RECT lpRect, int nCount);
public static extern bool RedrawWindow(HandleRef hwnd, ref System.Windows.Forms.NativeMethods.RECT rcUpdate, HandleRef hrgnUpdate, int flags);
private unsafe void TvnSelected(System.Windows.Forms.NativeMethods.NMTREEVIEW* nmtv) { if (!this.nodesCollectionClear) { if (nmtv.itemNew.hItem != IntPtr.Zero) { TreeViewAction unknown = TreeViewAction.Unknown; switch (nmtv.action) { case 1: unknown = TreeViewAction.ByMouse; break; case 2: unknown = TreeViewAction.ByKeyboard; break; } this.OnAfterSelect(new TreeViewEventArgs(this.NodeFromHandle(nmtv.itemNew.hItem), unknown)); } System.Windows.Forms.NativeMethods.RECT lParam = new System.Windows.Forms.NativeMethods.RECT(); (IntPtr) &lParam.left = nmtv.itemOld.hItem; if ((nmtv.itemOld.hItem != IntPtr.Zero) && (((int) ((long) System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, base.Handle), 0x1104, 1, ref lParam))) != 0)) { System.Windows.Forms.SafeNativeMethods.InvalidateRect(new HandleRef(this, base.Handle), ref lParam, true); } } }
public static extern int ScrollWindowEx(HandleRef hWnd, int nXAmount, int nYAmount, System.Windows.Forms.NativeMethods.COMRECT rectScrollRegion, ref System.Windows.Forms.NativeMethods.RECT rectClip, HandleRef hrgnUpdate, ref System.Windows.Forms.NativeMethods.RECT prcUpdate, int flags);
private void ShowTooltip(string text, IWin32Window win, int duration) { if (win == null) { throw new ArgumentNullException("win"); } Control wrapper = win as Control; if (wrapper != null) { System.Windows.Forms.NativeMethods.RECT rect = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.UnsafeNativeMethods.GetWindowRect(new HandleRef(wrapper, wrapper.Handle), ref rect); Cursor currentInternal = Cursor.CurrentInternal; Point position = Cursor.Position; Point p = position; Screen screen = Screen.FromPoint(position); if (((position.X < rect.left) || (position.X > rect.right)) || ((position.Y < rect.top) || (position.Y > rect.bottom))) { System.Windows.Forms.NativeMethods.RECT rect2 = new System.Windows.Forms.NativeMethods.RECT { left = (rect.left < screen.WorkingArea.Left) ? screen.WorkingArea.Left : rect.left, top = (rect.top < screen.WorkingArea.Top) ? screen.WorkingArea.Top : rect.top, right = (rect.right > screen.WorkingArea.Right) ? screen.WorkingArea.Right : rect.right, bottom = (rect.bottom > screen.WorkingArea.Bottom) ? screen.WorkingArea.Bottom : rect.bottom }; p.X = rect2.left + ((rect2.right - rect2.left) / 2); p.Y = rect2.top + ((rect2.bottom - rect2.top) / 2); wrapper.PointToClientInternal(p); this.SetTrackPosition(p.X, p.Y); this.SetTool(win, text, TipInfo.Type.SemiAbsolute, p); if (duration > 0) { this.StartTimer(this.window, duration); } } else { TipInfo info = (TipInfo) this.tools[wrapper]; if (info == null) { info = new TipInfo(text, TipInfo.Type.SemiAbsolute); } else { info.TipType |= TipInfo.Type.SemiAbsolute; info.Caption = text; } info.Position = p; if (duration > 0) { if (this.originalPopupDelay == 0) { this.originalPopupDelay = this.AutoPopDelay; } this.AutoPopDelay = duration; } this.SetToolTipInternal(wrapper, info); } } }
public Rectangle GetTabRect(int index) { if ((index < 0) || ((index >= this.tabPageCount) && !this.tabControlState[8])) { throw new ArgumentOutOfRangeException("index", System.Windows.Forms.SR.GetString("InvalidArgument", new object[] { "index", index.ToString(CultureInfo.CurrentCulture) })); } this.tabControlState[8] = false; System.Windows.Forms.NativeMethods.RECT lparam = new System.Windows.Forms.NativeMethods.RECT(); if (!base.IsHandleCreated) { this.CreateHandle(); } base.SendMessage(0x130a, index, ref lparam); return Rectangle.FromLTRB(lparam.left, lparam.top, lparam.right, lparam.bottom); }
public Rectangle GetItemRectangle(int index) { this.CheckIndex(index); System.Windows.Forms.NativeMethods.RECT lparam = new System.Windows.Forms.NativeMethods.RECT(); base.SendMessage(0x198, index, ref lparam); return Rectangle.FromLTRB(lparam.left, lparam.top, lparam.right, lparam.bottom); }
private Rectangle GetItemRectOrEmpty(int index) { if ((index < 0) || (index >= this.Items.Count)) { return Rectangle.Empty; } if ((this.View == System.Windows.Forms.View.Details) && (this.Columns.Count == 0)) { return Rectangle.Empty; } System.Windows.Forms.NativeMethods.RECT lparam = new System.Windows.Forms.NativeMethods.RECT { left = 0 }; if (((int) ((long) base.SendMessage(0x100e, index, ref lparam))) == 0) { return Rectangle.Empty; } return Rectangle.FromLTRB(lparam.left, lparam.top, lparam.right, lparam.bottom); }
private void WmMove() { System.Windows.Forms.NativeMethods.RECT rect = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.UnsafeNativeMethods.GetWindowRect(new HandleRef(this, this.Handle), ref rect); System.Windows.Forms.NativeMethods.TOOLINFO_TOOLTIP lParam = new System.Windows.Forms.NativeMethods.TOOLINFO_TOOLTIP { cbSize = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.TOOLINFO_TOOLTIP)) }; if (((int) System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, this.Handle), System.Windows.Forms.NativeMethods.TTM_GETCURRENTTOOL, 0, lParam)) != 0) { IWin32Window window = (IWin32Window) this.owners[lParam.hwnd]; if (window == null) { window = Control.FromHandleInternal(lParam.hwnd); } if (window != null) { TipInfo info = (TipInfo) this.tools[window]; if ((window != null) && (info != null)) { TreeView view = window as TreeView; if (((view == null) || !view.ShowNodeToolTips) && (info.Position != Point.Empty)) { this.Reposition(info.Position, rect.Size); } } } } }
public int IndexFromPoint(int x, int y) { System.Windows.Forms.NativeMethods.RECT rect = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.UnsafeNativeMethods.GetClientRect(new HandleRef(this, base.Handle), ref rect); if (((rect.left <= x) && (x < rect.right)) && ((rect.top <= y) && (y < rect.bottom))) { int n = (int) ((long) base.SendMessage(0x1a9, 0, (int) ((long) System.Windows.Forms.NativeMethods.Util.MAKELPARAM(x, y)))); if (System.Windows.Forms.NativeMethods.Util.HIWORD(n) == 0) { return System.Windows.Forms.NativeMethods.Util.LOWORD(n); } } return -1; }
private void WmShow() { System.Windows.Forms.NativeMethods.RECT rect = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.UnsafeNativeMethods.GetWindowRect(new HandleRef(this, this.Handle), ref rect); System.Windows.Forms.NativeMethods.TOOLINFO_TOOLTIP lParam = new System.Windows.Forms.NativeMethods.TOOLINFO_TOOLTIP { cbSize = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.TOOLINFO_TOOLTIP)) }; if (((int) System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, this.Handle), System.Windows.Forms.NativeMethods.TTM_GETCURRENTTOOL, 0, lParam)) != 0) { IWin32Window associatedWindow = (IWin32Window) this.owners[lParam.hwnd]; if (associatedWindow == null) { associatedWindow = Control.FromHandleInternal(lParam.hwnd); } if (associatedWindow != null) { Control associatedControl = associatedWindow as Control; Size size = rect.Size; PopupEventArgs e = new PopupEventArgs(associatedWindow, associatedControl, this.IsBalloon, size); this.OnPopup(e); DataGridView view = associatedControl as DataGridView; if ((view != null) && view.CancelToolTipPopup(this)) { e.Cancel = true; } System.Windows.Forms.UnsafeNativeMethods.GetWindowRect(new HandleRef(this, this.Handle), ref rect); size = (e.ToolTipSize == size) ? rect.Size : e.ToolTipSize; if (this.IsBalloon) { System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, this.Handle), 0x41f, 1, ref rect); if (rect.Size.Height > size.Height) { size.Height = rect.Size.Height; } } if (size != rect.Size) { Screen screen = Screen.FromPoint(Cursor.Position); int num2 = this.IsBalloon ? Math.Min(size.Width - 20, screen.WorkingArea.Width) : Math.Min(size.Width, screen.WorkingArea.Width); System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, this.Handle), 0x418, 0, num2); } if (e.Cancel) { this.cancelled = true; System.Windows.Forms.SafeNativeMethods.SetWindowPos(new HandleRef(this, this.Handle), System.Windows.Forms.NativeMethods.HWND_TOPMOST, 0, 0, 0, 0, 0x210); } else { this.cancelled = false; System.Windows.Forms.SafeNativeMethods.SetWindowPos(new HandleRef(this, this.Handle), System.Windows.Forms.NativeMethods.HWND_TOPMOST, rect.left, rect.top, size.Width, size.Height, 0x210); } } } }
protected void CenterToParent() { if (this.TopLevel) { Point point = new Point(); System.Drawing.Size size = this.Size; IntPtr zero = IntPtr.Zero; zero = System.Windows.Forms.UnsafeNativeMethods.GetWindowLong(new HandleRef(this, base.Handle), -8); if (zero != IntPtr.Zero) { Rectangle workingArea = Screen.FromHandleInternal(zero).WorkingArea; System.Windows.Forms.NativeMethods.RECT rect = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.UnsafeNativeMethods.GetWindowRect(new HandleRef(null, zero), ref rect); point.X = ((rect.left + rect.right) - size.Width) / 2; if (point.X < workingArea.X) { point.X = workingArea.X; } else if ((point.X + size.Width) > (workingArea.X + workingArea.Width)) { point.X = (workingArea.X + workingArea.Width) - size.Width; } point.Y = ((rect.top + rect.bottom) - size.Height) / 2; if (point.Y < workingArea.Y) { point.Y = workingArea.Y; } else if ((point.Y + size.Height) > (workingArea.Y + workingArea.Height)) { point.Y = (workingArea.Y + workingArea.Height) - size.Height; } this.Location = point; } else { this.CenterToScreen(); } } }
public void Show(string text, IWin32Window window, int x, int y) { if (window == null) { throw new ArgumentNullException("window"); } if (this.HasAllWindowsPermission && this.IsWindowActive(window)) { System.Windows.Forms.NativeMethods.RECT rect = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.UnsafeNativeMethods.GetWindowRect(new HandleRef(window, Control.GetSafeHandle(window)), ref rect); int pointX = rect.left + x; int pointY = rect.top + y; this.SetTrackPosition(pointX, pointY); this.SetTool(window, text, TipInfo.Type.Absolute, new Point(pointX, pointY)); } }
public void Show(string text, IWin32Window window, int x, int y, int duration) { if (window == null) { throw new ArgumentNullException("window"); } if (duration < 0) { object[] args = new object[] { "duration", duration.ToString(CultureInfo.CurrentCulture), 0.ToString(CultureInfo.CurrentCulture) }; throw new ArgumentOutOfRangeException("duration", System.Windows.Forms.SR.GetString("InvalidLowBoundArgumentEx", args)); } if (this.HasAllWindowsPermission && this.IsWindowActive(window)) { System.Windows.Forms.NativeMethods.RECT rect = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.UnsafeNativeMethods.GetWindowRect(new HandleRef(window, Control.GetSafeHandle(window)), ref rect); int pointX = rect.left + x; int pointY = rect.top + y; this.SetTrackPosition(pointX, pointY); this.SetTool(window, text, TipInfo.Type.Absolute, new Point(pointX, pointY)); this.StartTimer(window, duration); } }
public static extern bool DrawEdge(HandleRef hDC, ref System.Windows.Forms.NativeMethods.RECT rect, int edge, int flags);
private void WmMouseActivate(ref Message msg) { System.Windows.Forms.NativeMethods.TOOLINFO_TOOLTIP lParam = new System.Windows.Forms.NativeMethods.TOOLINFO_TOOLTIP { cbSize = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.TOOLINFO_TOOLTIP)) }; if (((int) System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, this.Handle), System.Windows.Forms.NativeMethods.TTM_GETCURRENTTOOL, 0, lParam)) != 0) { IWin32Window wrapper = (IWin32Window) this.owners[lParam.hwnd]; if (wrapper == null) { wrapper = Control.FromHandleInternal(lParam.hwnd); } if (wrapper != null) { System.Windows.Forms.NativeMethods.RECT rect = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.UnsafeNativeMethods.GetWindowRect(new HandleRef(wrapper, Control.GetSafeHandle(wrapper)), ref rect); Point position = Cursor.Position; if (((position.X >= rect.left) && (position.X <= rect.right)) && ((position.Y >= rect.top) && (position.Y <= rect.bottom))) { msg.Result = (IntPtr) 3; } } } }