Jump to content
Software FX Community

CreateGraphics


User (Legacy)

Recommended Posts

Hi-

I am using Chart FX Lite in C# to produce graphs, works great. However, when

I use a the CreateGraphics method to get a graphics handle followed by a

BitBlt to capture the chart, it seems to capture the contents of the desktop

behind the requested chart or form. This happens if I use the CreateGraphics

on either the chart or the form that contains it. Interestingly, if I use

the same code on the form without the chart in it, I get the expected

results.

Is this due to a license thing or ? THANKS.

CODE SAMPLE:

const int SRCCOPY = 0x00CC0020;

const int CAPTUREBLT = 0x40000000;

Graphics g1 = form.CreateGraphics();

Image im = new Bitmap(form.ClientRectangle.Width,

form.ClientRectangle.Height, g1);

Graphics g2 = Graphics.FromImage(im);

IntPtr dc1 = g1.GetHdc();

IntPtr dc2 = g2.GetHdc();

BitBlt(dc2, 0, 0, form.ClientRectangle.Width, form.ClientRectangle.Height,

dc1, 0, 0, SRCCOPY);

g1.ReleaseHdc(dc1);

g2.ReleaseHdc(dc2);

im.Save( @"D:\im.png",ImageFormat.Png);

g1.Dispose();

---

Outgoing mail is certified Virus Free.

Checked by AVG anti-virus system (http://www.grisoft.com).

Version: 6.0.744 / Virus Database: 496 - Release Date: 8/24/2004

Link to comment
Share on other sites

Hi-

I am using Chart FX Lite in C# to produce graphs, works great. However, when

I use a the CreateGraphics method to get a graphics handle followed by a

BitBlt to capture the chart, it seems to capture the contents of the desktop

behind the requested chart or form. This happens if I use the CreateGraphics

on either the chart or the form that contains it. Interestingly, if I use

the same code on the form without the chart in it, I get the expected

results.

Is this due to a license thing or ? THANKS.

CODE SAMPLE:

const int SRCCOPY = 0x00CC0020;

const int CAPTUREBLT = 0x40000000;

Graphics g1 = form.CreateGraphics();

Image im = new Bitmap(form.ClientRectangle.Width,

form.ClientRectangle.Height, g1);

Graphics g2 = Graphics.FromImage(im);

IntPtr dc1 = g1.GetHdc();

IntPtr dc2 = g2.GetHdc();

BitBlt(dc2, 0, 0, form.ClientRectangle.Width, form.ClientRectangle.Height,

dc1, 0, 0, SRCCOPY);

g1.ReleaseHdc(dc1);

g2.ReleaseHdc(dc2);

im.Save( @"D:\im.png",ImageFormat.Png);

g1.Dispose();

---

Outgoing mail is certified Virus Free.

Checked by AVG anti-virus system (http://www.grisoft.com).

Version: 6.0.744 / Virus Database: 496 - Release Date: 8/24/2004

Link to comment
Share on other sites

Never mind, I found the problem was that I needed to do a Refresh() on the

form before attempting to capture it. Odd in that it shows on the screen

fine but without this call the controls embedded in the form would not

appear in the capture.

---

Outgoing mail is certified Virus Free.

Checked by AVG anti-virus system (http://www.grisoft.com).

Version: 6.0.744 / Virus Database: 496 - Release Date: 8/24/2004

Link to comment
Share on other sites

Never mind, I found the problem was that I needed to do a Refresh() on the

form before attempting to capture it. Odd in that it shows on the screen

fine but without this call the controls embedded in the form would not

appear in the capture.

---

Outgoing mail is certified Virus Free.

Checked by AVG anti-virus system (http://www.grisoft.com).

Version: 6.0.744 / Virus Database: 496 - Release Date: 8/24/2004

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...