c#有关多屏截图的问题遮蔽画不到第二个屏

星海穿梭者 2017-08-01 05:10:35
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;
this.FormBorderStyle = FormBorderStyle.None;

this.DesktopBounds = 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.CopyFromScreen(new Point(0, 0), new Point(0, 0), Screen.AllScreens[xy].Bounds.Size);
g.Dispose();
//将有遮罩的图像作为背景
//BackgroundImage = ScreenImage;
//BackgroundImage = GetDestopImage();
BackgroundImage =GetDestopImage();

try
{
_selectCursor = new Cursor(Properties.Resources.Arrow_M.Handle);
}

Screen sr = Screen.AllScreens[xy];
Rectangle rect = sr.Bounds;
Bitmap bmp = new Bitmap(rect.Width, rect.Height, PixelFormat.Format64bppPArgb);

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;
...全文
531 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
星海穿梭者 2017-08-02
  • 打赏
  • 举报
回复
上面的方法还是不行

110,537

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧