TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Guill
NA
3
0
Print error
Mar 19 2009 2:57 PM
Hello,
I hope someone can help me. I try to print an image and to draw a yellow rectangle with transparency, but it gives me a reading or writing protected memory error.
Here's the simplified code that reproduces the error:
private void PrintImage()
{
try
{
printDocument1.DocumentName = "Test";
printDocument1.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
printDocument1.Print();
}
catch (Exception e)
{
//reading or writing protected memory error
}
}
private void printDocument1_PrintPage(object sender, PrintPageEventArgs e) {
if (!e.Cancel)
{
Image printImg = Bitmap.FromFile("d:\\temp\\img.gif"); //PRINT1
//Image printImg = new Bitmap(1096, 2200); //PRINT2
e.Graphics.DrawImage(printImg, 0, 0, 800, 1000);
SolidBrush b = new SolidBrush(Color.FromArgb(110, Color.Yellow)); //BRUSH 1
//SolidBrush b = new SolidBrush(Color.Yellow); //BRUSH 2
e.Graphics.FillRectangle(b, 50, 50, 100, 100);
e.HasMorePages = false;
}
else
e.Cancel = true;
}
If I call the function PrintImage () that causes the error.
If I replace the line PRINT1 by PRINT2
OR
if I replace the line BRUSH1 by BRUSH2
=
the print works.
Thank you for your help.
Guill
Reply
Answers (
1
)
HOw to handle key board events
first_array[].second_array[].x1 is it possible?