Groups | Blog | Home
all groups > dotnet drawing api > may 2006 >

dotnet drawing api : Re: Graphics.PageUnit problem... (spelling checked.. ;-(


Lloyd Dupont
5/10/2006 2:19:32 PM
I have to do some WYSIWIG rendering.
Because I need to know exactly where is what and have to have the same
output on both the screen and the printer I decided to change my Page unit
to Inches.
As I was testing my first thought was to draw red outline of some relevant
rectangle.

And here I had my 1st encouter with those infamous Windows strangeness....
Even though I had set my line width to 0, GDI+ draw 1 inch thick
rectangles...
What's that?
How could I fix that?

Below is a code sample showing the problem,
just try it: big rectangle:
==========================
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);

e.Graphics.PageUnit = GraphicsUnit.Inch;

using (Pen pen = new Pen(Color.Red, 0))
{
pen.Width = 0;
e.Graphics.DrawRectangle(Pens.Red, 0, 0, 8.5f, 11);
e.Graphics.DrawRectangle(Pens.Red, 1.5f, 1.25f, 5.5f, 8.5f);
}
}



Lloyd Dupont
5/10/2006 3:56:40 PM
Never mind, obvious bug in my code...

--
Regards,
Lloyd Dupont

NovaMind development team
NovaMind Software
Mind Mapping Software
<www.nova-mind.com>
[quoted text, click to view]

Bob Powell [MVP]
5/10/2006 8:03:27 PM
To get 1 pixel regardless of page-units use a value of -1 not 0.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.



[quoted text, click to view]

Lloyd Dupont
5/12/2006 12:00:00 AM
[quoted text, click to view]

ho?
how strange.....
and what does 0 do differently?

[quoted text, click to view]

Lloyd Dupont
5/12/2006 12:00:00 AM
[quoted text, click to view]
I should add (as I previously answered my self) that it was a stupid bug in
my code and 0 seems to work fine...

[quoted text, click to view]

AddThis Social Bookmark Button