protected override void WndProc(ref Message m) { bool flag = true; switch (m.Msg) { case 0x7b: { Point pointFromLPARAM = Win32Util.GetPointFromLPARAM((int)m.LParam); pointFromLPARAM = base.PointToClient(pointFromLPARAM); this.contextMenu1.Show(this, pointFromLPARAM); break; } case 0x31a: if (this.m_htheme != IntPtr.Zero) { XPTheme.CloseThemeData(this.m_htheme); this.m_htheme = IntPtr.Zero; } base.Invalidate(); break; } if (flag) { base.WndProc(ref m); } }
protected override void Dispose(bool disposing) { if (disposing) { base.KeyPress -= new KeyPressEventHandler(this.KeyPressed); if (this.m_htheme != IntPtr.Zero) { XPTheme.CloseThemeData(this.m_htheme); } if (this.components != null) { this.components.Dispose(); } } base.Dispose(disposing); }
protected override void OnPaint(PaintEventArgs pe) { try { base.OnPaint(pe); Rectangle clientRectangle = base.ClientRectangle; ControlPaint.DrawBorder3D(pe.Graphics, clientRectangle, Border3DStyle.Sunken); if ((this.isCompatibleOS && (XPTheme.IsThemeActive() == 1)) && ((this.m_htheme == IntPtr.Zero) /* && (this.boxStyle == Style.XpStyle)*/)) { this.m_htheme = XPTheme.OpenThemeData(IntPtr.Zero, "Edit"); } IntPtr handle = this.Font.ToHfont(); IntPtr hdc = pe.Graphics.GetHdc(); Win32Util.SetBkMode(hdc, 1); Win32Util.SelectObject(hdc, handle); if (!base.Enabled) { Win32Util.SetTextColor(hdc, Color.FromName("ControlDarkDark")); } else if (this.sDisplay.IndexOf("-") != -1) { Win32Util.SetTextColor(hdc, this.m_NegativeColor); } else { Win32Util.SetTextColor(hdc, this.ForeColor); } if (this.m_htheme != IntPtr.Zero) { RECT rect = new RECT(base.ClientRectangle); IntPtr hd = hdc; XPTheme.DrawThemeBackground(this.m_htheme, hd, 1, base.Enabled ? 1 : 4, ref rect, ref rect); Rectangle clip = base.ClientRectangle; clip.Inflate(-1, -1); Win32Util.FillRect(hdc, clip, this.BackColor); } Size textExtent = Win32Util.GetTextExtent(hdc, this.sDisplay); Win32Util.ExtTextOut(hdc, (clientRectangle.Width - textExtent.Width) - this.nShiftLeft, clientRectangle.Y + 3, clientRectangle, this.sDisplay); if (this.m_nDecimalNumber > 0) { for (int i = 1; i <= (this.m_nDecimalNumber + 2); i++) { if (this.cp[i]) { Point point = new Point(); point.Y = 3; if (i < (this.m_nDecimalNumber + 2)) { string str = this.sDisplay.Substring(this.sDisplay.Length - ((this.m_nDecimalNumber + 2) - i), (this.m_nDecimalNumber + 2) - i); Size size2 = Win32Util.GetTextExtent(hdc, str); point.X = (clientRectangle.Width - size2.Width) - this.nShiftLeft; } else { point.X = clientRectangle.Width - this.nShiftLeft; } this.ptPos = point; if (this.Focused) { SetCaretPos(this.ptPos.X, this.ptPos.Y); } } } } else { Point point2 = new Point(); point2.Y = 3; point2.X = clientRectangle.Width - this.nShiftLeft; this.ptPos = point2; if (this.Focused) { SetCaretPos(this.ptPos.X, this.ptPos.Y); } } pe.Graphics.ReleaseHdc(hdc); if (this.sOldText != this.sDisplay) { this.sOldText = this.sDisplay; this.OnTextChanged(EventArgs.Empty); } } catch (Exception ex) { Debug.Write(ex.Message); } }