[DllImportAttribute("gdi32.dll")]
private static extern bool BitBlt(
IntPtr hdcDest,
int nXDest,
int nYDest,
int nWidth,
int nHeight,
IntPtr hdcSrc,
int nXSrc,
int nYSrc,
int dwRop);
代码
public Bitmap CaptureControl(Control control)
{
    Bitmap controlBmp;
    
using (Graphics g1 = control.CreateGraphics())
    {
        controlBmp 
= new Bitmap(control.Width, control.Height, g1);
        
using (Graphics g2 = Graphics.FromImage(controlBmp))
        {
            IntPtr dc1 
= g1.GetHdc();
            IntPtr dc2 
= g2.GetHdc();
            BitBlt(dc2, 
00, control.Width, control.Height, dc1, 0013369376);
            g1.ReleaseHdc(dc1);
            g2.ReleaseHdc(dc2);
        }
    }

    
return controlBmp;
}

 

 

 

http://www.vcskicks.com/capture-control-graphics.php

相关文章:

  • 2022-12-23
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
  • 2021-05-18
  • 2022-02-19
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-09
  • 2021-07-28
  • 2022-01-01
  • 2021-05-29
  • 2022-12-23
相关资源
相似解决方案