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);
}
}

Re: Graphics.PageUnit problem... (spelling checked.. ;-( by Lloyd

Lloyd
Wed May 10 00:56:40 CDT 2006

Never mind, obvious bug in my code...

--
Regards,
Lloyd Dupont

NovaMind development team
NovaMind Software
Mind Mapping Software
<www.nova-mind.com>
"Lloyd Dupont" <net.galador@ld> wrote in message
news:u$x8xj%23cGHA.5048@TK2MSFTNGP03.phx.gbl...
>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);
> }
> }
>
>
>
>



Re: Graphics.PageUnit problem... (spelling checked.. ;-( by Bob

Bob
Wed May 10 13:03:27 CDT 2006

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.



"Lloyd Dupont" <net.galador@ld> wrote in message
news:u$x8xj%23cGHA.5048@TK2MSFTNGP03.phx.gbl...
>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);
> }
> }
>
>
>
>



Re: Graphics.PageUnit problem... (spelling checked.. ;-( by Lloyd

Lloyd
Thu May 11 19:44:11 CDT 2006

> To get 1 pixel regardless of page-units use a value of -1 not 0.

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

>
> --
> 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.
>
>
>
> "Lloyd Dupont" <net.galador@ld> wrote in message
> news:u$x8xj%23cGHA.5048@TK2MSFTNGP03.phx.gbl...
>>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);
>> }
>> }
>>
>>
>>
>>
>
>



Re: Graphics.PageUnit problem... (spelling checked.. ;-( by Lloyd

Lloyd
Thu May 11 19:45:20 CDT 2006

> To get 1 pixel regardless of page-units use a value of -1 not 0.
>
I should add (as I previously answered my self) that it was a stupid bug in
my code and 0 seems to work fine...

> --
> 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.
>
>
>
> "Lloyd Dupont" <net.galador@ld> wrote in message
> news:u$x8xj%23cGHA.5048@TK2MSFTNGP03.phx.gbl...
>>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);
>> }
>> }
>>
>>
>>
>>
>
>