RaUI/Source/ryControls/Controls/NumericUpDownEx.cs
2020-11-28 15:03:57 +08:00

55 lines
1.9 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ryControls
{
/// <summary>
///
/// </summary>
public partial class NumericUpDownEx : NumericUpDown
{
/// <summary>
///
/// </summary>
public NumericUpDownEx()
{
InitializeComponent();
}
/// <summary>
///
/// </summary>
/// <param name="m"></param>
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
//WM_PAINT = 0xf; 要求一个窗口重画自己,即Paint事件时
//WM_CTLCOLOREDIT = 0x133;当一个编辑型控件将要被绘制时发送此消息给它的父窗口;
//通过响应这条消息,所有者窗口可以通过使用给定的相关显示设备的句柄来设置编辑框的文本和背景颜色
if (m.Msg == 0xf || m.Msg == 0x133)
{
IntPtr hDC = Win32.GetWindowDC(m.HWnd);
if (hDC.ToInt32() == 0) //如果取设备上下文失败则返回
{
return;
}
//建立Graphics对像
Graphics g = Graphics.FromHdc(hDC);
//画边框的
ControlPaint.DrawBorder(g, new Rectangle(0, 0, Width, Height), SkinHelp.DefalutBorderColor, ButtonBorderStyle.Solid);
//画坚线
//ControlPaint.DrawBorder(g, new Rectangle(Width - Height, 0, Height, Height), Color.Red, ButtonBorderStyle.Solid);
//g.DrawLine(new Pen(Brushes.Blue, 2), new PointF(this.Width - this.Height, 0), new PointF(this.Width - this.Height, this.Height));
//释放DC
Win32.ReleaseDC(m.HWnd, hDC);
}
}
}
}