|
楼主 |
发表于 2020-1-22 17:54:01
|
显示全部楼层
[DllImport ("User32.dll")]
private static extern IntPtr GetWindowDC(IntPtr hwnd);
[DllImport ("User32.dll")]
private static extern int ReleaseDC(IntPtr hwnd, IntPtr hdc);
[DllImport ("Kernel32.dll")]
private static extern int GetLastError();
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
switch(m.Msg)
{
case 0x86://WM_NCACTIVATE
goto case 0x85;
case 0x85://WM_NCPAINT
{
IntPtr hDC = GetWindowDC(m.HWnd);
Graphics gs = Graphics.FromHdc(hDC);
Rectangle m_rect = new Rectangle(0, 0, 300, 300);
gs.FillRectangle(new LinearGradientBrush(m_ret, Color.Pink, Color.Pink, LinearGradientMode.BackwardDiagonal), m_rect);
StringFormat strFmt = new StringFormat();
strFmt.Alignment = StringAlignment.Center;
strFmt.LineAlignment = StringAlignment.Center;
gs.DrawString("√", this.Font, Brushes.BlanchedAlmond, m_rect, strFmt);
gs.Dispose();
//释放GDI资源
ReleaseDC(m.HWnd, hDC);
break;
}
}
我的代码大概就系这样。。你们可以试试看看。我只是想去掉原来的颜色。。。。 |
|