采用的API:
[System.Runtime.InteropServices.DllImport("user32")]
private static extern IntPtr GetDC(IntPtr hwnd);
[System.Runtime.InteropServices.DllImport("gdi32")]
private static extern int BitBlt(IntPtr hDestDC, int x, int y, int nWidth, int nHeight, IntPtr hSrcDC, int xSrc, int ySrc, int dwRop);
const int COLOR = 0xc00000;
代码:
int i, j;
IntPtr handle1;
IntPtr handle2;
handle1 = GetDC(this.pictureBox1.Handle);
handle2 = GetDC(this.pictureBox2.Handle);
for (i = 0; i < this.pictureBox1.Width / 22; i++)//百页窗数
{
for (j = 0; j < 22; j++)//刷屏的大小
{
BitBlt(handle2, j * this.pictureBox1.Width / 22, 0, i + 2, this.pictureBox1.Height, handle1, j * this.pictureBox1.Width / 22, 0, COLOR);
}
System.Threading.Thread.Sleep(300);//刷屏的速度
}