Hi
I have a C# application that should display a chart, the chart drawing
is done by a COM object. I have tried to use dllimport with gdi32.dll
and created compatibleDC and compatibleBitmap with the hdc from the
graphics object. The COM object is trying to draw on the compatibleDC
and I try to create a bitmap from the hdc when the c++ drawing is
finished. The image is not displaying anything, it is just black.
How is it possible to display a bitmap created from a hdc in a c#
application when the drawing is done from a C++ COM object?
Here is my sample code:
IntPtr hDC = this.CreateGraphics().GetHdc();
IntPtr hMemDC = CreateCompatibleDC(hDC); //Call gdi32.dll
IntPtr hBitmap = CreateCompatibleBitmap(hDC);//Call gdi32.dll
SelectObject(hMemDC,hBitmap);//Call gdi32.dll
DrawChart(hMemDC);//The chart drawing done by the COM object
Bitmap bmp = System.Drawing.Image.FromHbitmap(hBitmap);
pictureBox1.Image = bmp;
Can anybody please tell me what I'm doing wrong?
Thanks!
Espen