1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
public partial class EVCombobox : ComboBox { public EVCombobox() { InitializeComponent(); } [DllImport("User32.dll")] public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
public Color BoardColor { get; set; } = Color.White;
protected override void WndProc(ref Message m) { base.WndProc(ref m); if (m.Msg == 0xf || m.Msg == 0x133) { IntPtr hDC = Win32API.GetWindowDC(m.HWnd); if (hDC.ToInt32() == 0) { return; }
Graphics g = Graphics.FromHdc(hDC); g.FillRectangle(new SolidBrush(BackColor), new Rectangle(0, 0, Width, Height));
Point pA = new Point(Width - 20, Height / 2 - 3); Point pB = pA + new Size(6, 6); Point pC = pA + new Size(12, 0); g.DrawLine(new Pen(Color.White,2), pA, pB); g.DrawLine(new Pen(Color.White,2), pB, pC);
if (this.SelectedIndex > -1) { string text = SelectedItem.ToString(); Size strSize = Size.Ceiling(g.MeasureString(text, this.Font)); g.DrawString(text, Font, new SolidBrush(ForeColor), 5, (Height - strSize.Height) / 2); }
ReleaseDC(m.HWnd, hDC); } } }
|