SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);
//双缓冲绘制,避免闪烁
//this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
XY();
drawToolsControl.Visible = false;
colorSelector.Visible = false;
textBox.Visible = false;
this.TopMost = true;
this.ShowInTaskbar = false;
this.FormBorderStyle = FormBorderStyle.None;
Bounds = Screen.AllScreens[xy].Bounds;
//保留当前屏
ScreenImage = GetDestopImage();
//复制当前屏
Image BackScreen = new Bitmap(ScreenImage);
Graphics g = Graphics.FromImage(BackScreen);
//画遮罩
g.FillRectangle(mask, 0, 0, BackScreen.Width, BackScreen.Height);
g.Dispose();
//将有遮罩的图像作为背景
this.BackgroundImage = BackScreen;
//BackgroundImage = GetDestopImage();
try
{
_selectCursor = new Cursor(Properties.Resources.Arrow_M.Handle);
}
catch { }
Cursor = SelectCursor;
private Image GetDestopImage()
{
Rectangle rect = Screen.AllScreens[xy].Bounds;
Bitmap bmp = new Bitmap(
rect.Width, rect.Height, PixelFormat.Format32bppArgb);
Graphics g = Graphics.FromImage(bmp);
IntPtr gHdc = g.GetHdc();
IntPtr deskHandle = NativeMethods.GetDesktopWindow();
IntPtr dHdc = NativeMethods.GetDC(deskHandle);
NativeMethods.BitBlt(
gHdc,
0,
0,
Width,
Height,
dHdc,
0,
0,
NativeMethods.TernaryRasterOperations.SRCCOPY);
NativeMethods.ReleaseDC(deskHandle, dHdc);
g.ReleaseHdc(gHdc);
return bmp;
}