G
Guest
Hello,
I'm using a control (black box control) in my form (an ActiveX/Com control).
and I need to take the control as an image.
The controls is showing some kind of graph, and I want to create a bitmap
file out of this control, so the bitmap will show what the control is showing.
I tried this:
/////////////////////////////////////////////////////////////////
AxTheControl.AxControl ctrl = new AxTheControl.AxControl();
Graphics graphics = ctrl.CreateGraphics();
IntPtr hdc = graphics.GetHdc();
try
{
Bitmap bitmap = Bitmap.FromHbitmap(hdc);
bitmap.Save("C\ControlImage.bmp");
}
catch( Exception exp )
{
MessageBox.Show(exp.Message,);
}
graphics.ReleaseHdc(hdc);
graphics.Dispose();
/////////////////////////////////////////////////////////////////
But is throws a GDI+ general error exception.
Does anybody knows how can I do that?
I'm using a control (black box control) in my form (an ActiveX/Com control).
and I need to take the control as an image.
The controls is showing some kind of graph, and I want to create a bitmap
file out of this control, so the bitmap will show what the control is showing.
I tried this:
/////////////////////////////////////////////////////////////////
AxTheControl.AxControl ctrl = new AxTheControl.AxControl();
Graphics graphics = ctrl.CreateGraphics();
IntPtr hdc = graphics.GetHdc();
try
{
Bitmap bitmap = Bitmap.FromHbitmap(hdc);
bitmap.Save("C\ControlImage.bmp");
}
catch( Exception exp )
{
MessageBox.Show(exp.Message,);
}
graphics.ReleaseHdc(hdc);
graphics.Dispose();
/////////////////////////////////////////////////////////////////
But is throws a GDI+ general error exception.
Does anybody knows how can I do that?