protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { if (_backDc != null) { _backDc.Dispose(); _backDc = null; } if (!_titleFont.IsSystemFont) { _titleFont.Dispose(); } _titleFont = null; _image = null; _colorTable = null; } }
private void TipCapture() { IntPtr handle = Handle; if (handle == IntPtr.Zero) { return; } RECT rect = new RECT(); NativeMethods.GetWindowRect(handle, ref rect); Size size = new Size( rect.Right - rect.Left, rect.Bottom - rect.Top); _backDc = new ImageDc(size.Width, size.Height); IntPtr pD = NativeMethods.GetDesktopWindow(); IntPtr pH = NativeMethods.GetDC(pD); NativeMethods.BitBlt( _backDc.Hdc, 0, 0, size.Width, size.Height, pH, rect.Left, rect.Top, 0xCC0020); NativeMethods.ReleaseDC(pD, pH); }
private void DrawScrollBar(IntPtr maskHWnd, Rectangle bounds, Rectangle trackRect, Rectangle topLeftArrowRect, Rectangle bottomRightArrowRect, Rectangle thumbRect, ControlState topLeftArrowState, ControlState bottomRightArrowState, ControlState thumbState, Orientation direction) { bool bHorizontal = direction == Orientation.Horizontal; bool bEnabled = this._owner.Enabled; IScrollBarPaint paint = this._owner as IScrollBarPaint; if (paint != null) { ImageDc tempDc = new ImageDc(bounds.Width, bounds.Height); IntPtr hdc = CCWin.Win32.NativeMethods.GetDC(maskHWnd); try { using (Graphics g = Graphics.FromHdc(tempDc.Hdc)) { using (PaintScrollBarTrackEventArgs te = new PaintScrollBarTrackEventArgs(g, trackRect, direction, bEnabled)) { paint.OnPaintScrollBarTrack(te); } ArrowDirection arrowDirection = bHorizontal ? ArrowDirection.Left : ArrowDirection.Up; using (PaintScrollBarArrowEventArgs te = new PaintScrollBarArrowEventArgs(g, topLeftArrowRect, topLeftArrowState, arrowDirection, direction, bEnabled)) { paint.OnPaintScrollBarArrow(te); } arrowDirection = bHorizontal ? ArrowDirection.Right : ArrowDirection.Down; using (PaintScrollBarArrowEventArgs te = new PaintScrollBarArrowEventArgs(g, bottomRightArrowRect, bottomRightArrowState, arrowDirection, direction, bEnabled)) { paint.OnPaintScrollBarArrow(te); } using (PaintScrollBarThumbEventArgs te = new PaintScrollBarThumbEventArgs(g, thumbRect, thumbState, direction, bEnabled)) { paint.OnPaintScrollBarThumb(te); } } CCWin.Win32.NativeMethods.BitBlt(hdc, 0, 0, bounds.Width, bounds.Height, tempDc.Hdc, 0, 0, 0xcc0020); } finally { CCWin.Win32.NativeMethods.ReleaseDC(maskHWnd, hdc); tempDc.Dispose(); } } }