private static int WM_NCPAINT = 0×0085;
private static int WM_ERASEBKGND = 0×0014;
private static int WM_PAINT = 0×000F;
[DllImport(“user32.dll”)]
static extern IntPtr GetDCEx(IntPtr hwnd, IntPtr hrgnclip, uint fdwOptions);
DllImport(“user32.dll”)]
static extern int ReleaseDC(IntPtr hwnd, IntPtr hDC);
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == WM_NCPAINT || m.Msg == WM_ERASEBKGND || m.Msg == WM_PAINT)
{
IntPtr hdc = GetDCEx(m.HWnd, (IntPtr)1, 1 | 0×0020);
if (hdc != IntPtr.Zero)
{
Graphics graphics = Graphics.FromHdc(hdc);
Color borderColor = Color.Blue;
Rectangle rectangle = new Rectangle(0, 0, this.Width, this.Height);
ControlPaint.DrawBorder(graphics, rectangle, borderColor, ButtonBorderStyle.Solid);
m.Result = (IntPtr)1;
ReleaseDC(m.HWnd, hdc);
}
}
}
Lyon - 69003
Recent Comments