日期:2014-05-17 浏览次数:21331 次
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); IntPtr hdc = GetDC(Handle); mdc = CreateCompatibleDC(hdc); IntPtr hbmp = CreateCompatibleBitmap(hdc, ClientSize.Width, ClientSize.Width); SelectObject(mdc, hbmp); //从mdc中构建Graphics对象 Graphics g = Graphics.FromHdc(mdc); //SetBkMode(mdc, TRANSPARENT); g.DrawImage(_CloseBmp, ClientRectangle, 0, 0, _CloseBmp.Width, _CloseBmp.Height, GraphicsUnit.Pixel); AlphaBlend(hdc, 0, 0, ClientRectangle.Width, ClientRectangle.Height, mdc, 0, 0, ClientRectangle.Width, ClientRectangle.Height, new BLENDFUNCTION(255)); DeleteDC(mdc); DeleteObject(hbmp); ReleaseDC(Handle, hdc); }