using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace TestDLL
{
public partial class Form1 : Form
{
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern long BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);
ArrayList arry=new ArrayList();
public Form1()
{
InitializeComponent();
this.Paint += new PaintEventHandler(Form1_Paint);
}
void Form1_Paint(object sender, PaintEventArgs e)
{
for (int i = 0; i < arry.Count; i++)
{
e.Graphics.DrawImage(((Bitmap)((object[])arry[i])[0]), ((Point)((object[])arry[i])[1]));
}
}
private void DrawImage(Control c)
{
Size s = c.Size;
Graphics mygraphics=c.CreateGraphics();
IntPtr dc1;
IntPtr dc2;
Bitmap memoryImage = new Bitmap(s.Width, s.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics memoryGraphics = Graphics.FromImage(memoryImage);
dc1 = mygraphics.GetHdc();
dc2 = memoryGraphics.GetHdc();
BitBlt(dc2, 0, 0, c.ClientRectangle.Width, c.ClientRectangle.Height, dc1, 0, 0, 13369376);
mygraphics.ReleaseHdc(dc1);
memoryGraphics.ReleaseHdc(dc2);
Point p = new Point(c.Location.X, c.Location.Y);
Panel pa = new Panel();
object[] obj ={ memoryImage, p};
arry.Add(obj);
c.Visible = false;
this.Refresh();
}
private void button1_Click(object sender, EventArgs e)
{
DrawImage(this.treeView1);
DrawImage(this.comboBox1);
}
}
}