G
gsb58
Hi!
On a form I have a monthCalendar which display all months of year. Now,
as a training case here at school in C#, I'm trying to print the
calendar.
I've found, I think a good example how to print graphics, but it
doesn't work quite as I would expect.
Here's the code I found ("kalle" is the monthCalendar):
[DllImport("gdi32.dll")]
private static extern bool BitBlt(
IntPtr hdcDest, // handle to destination DC
int nXDest, // x-coord of destination upper-left corner
int nYDest, // y-coord of destination upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
IntPtr hdcSrc, // handle to source DC
int nXSrc, // x-coordinate of source upper-left corner
int nYSrc, // y-coordinate of source upper-left corner
System.Int32 dwRop // raster operation code
);
private const Int32 SRCCOPY = 0xCC0020;
private Bitmap memImage;
private void PrepareImage()
{
Graphics graphic = kalle.CreateGraphics();
Size s = this.Size;
memImage = new Bitmap(s.Width, s.Height, graphic);
Graphics memGraphic = Graphics.FromImage(memImage);
IntPtr dc1 = graphic.GetHdc();
IntPtr dc2 = memGraphic.GetHdc();
BitBlt(dc2, 0, 0, kalle.ClientRectangle.Width,
kalle.ClientRectangle.Height, dc1, 0, 0, SRCCOPY);
graphic.ReleaseHdc(dc1);
memGraphic.ReleaseHdc(dc2);
}
However, at loading the form I get a debugwindow loading, saying:
"The type or namespace 'DllImport' could not be found"
What do I need to add in the header?
Me.Name
(Just took the MCP-cert. on SQL-Server 2000)
On a form I have a monthCalendar which display all months of year. Now,
as a training case here at school in C#, I'm trying to print the
calendar.
I've found, I think a good example how to print graphics, but it
doesn't work quite as I would expect.
Here's the code I found ("kalle" is the monthCalendar):
[DllImport("gdi32.dll")]
private static extern bool BitBlt(
IntPtr hdcDest, // handle to destination DC
int nXDest, // x-coord of destination upper-left corner
int nYDest, // y-coord of destination upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
IntPtr hdcSrc, // handle to source DC
int nXSrc, // x-coordinate of source upper-left corner
int nYSrc, // y-coordinate of source upper-left corner
System.Int32 dwRop // raster operation code
);
private const Int32 SRCCOPY = 0xCC0020;
private Bitmap memImage;
private void PrepareImage()
{
Graphics graphic = kalle.CreateGraphics();
Size s = this.Size;
memImage = new Bitmap(s.Width, s.Height, graphic);
Graphics memGraphic = Graphics.FromImage(memImage);
IntPtr dc1 = graphic.GetHdc();
IntPtr dc2 = memGraphic.GetHdc();
BitBlt(dc2, 0, 0, kalle.ClientRectangle.Width,
kalle.ClientRectangle.Height, dc1, 0, 0, SRCCOPY);
graphic.ReleaseHdc(dc1);
memGraphic.ReleaseHdc(dc2);
}
However, at loading the form I get a debugwindow loading, saying:
"The type or namespace 'DllImport' could not be found"
What do I need to add in the header?
Me.Name
(Just took the MCP-cert. on SQL-Server 2000)