wavemill wrote:
I would like copy my control in a bitmap and after in a jpeg.
I have an error of gdi!
This is my code
System.IntPtr intPtr = this.RichTextBox.Handle;
System.Drawing.Image img = Bitmap.FromHbitmap(intPtr);
img.Save(@"Mypath\test.jpg",System.Drawing.Imagin g.ImageFormat.Jpeg);
That handle returned by the RichTextBox is not a HBitmap, unsurprisingly,
so this doesn't work. The FromHBitmap method works only on handles that
actually belong to a Windows bitmap.
There are two ways of solving your problem, depending on your .NET
version. In .NET 2, there's a new method on the Control, called
DrawToBitmap - this is obviously the easiest thing to use if you're on
..NET 2. In .NET 1, you'll have to reproduce the functionality of that
method yourself. I have recently done that for a blog article - see
http://www.sturmnet.org/blog/archive...-rubber-band2/ ,
right down at the bottom in the comments is the .NET implementation you
need and the sample source code tells you all about using it.
Oliver Sturm
--
Expert programming and consulting services available
See
http://www.sturmnet.org (try /blog as well)