A too large Rectangle

Tech-Archive recommends: Speed Up your PC by fixing your registry



Hello

I used the following code to draw a rectangle inside another rectangle (2
pixels smaller).
The inside rectangle results 1 pixel larger than the needed rectangle.

I had the same result with DrawPath when I was triyng to draw a
Rounded-Corners rectangle.

This is driving me crazy.
What's wrong?
Thank you


Dim rect1 As Rectangle
Dim insideRect As Rectangle
Dim pen As Pen

rect1 = New Rectangle(50, 50, 50, 50)
e.Graphics.FillRectangle(New SolidBrush(Color.Pink), rect1)
insideRect = New Rectangle(rect1.X + 2, rect1.Y + 2, rect1.Width - 4,
rect1.Height - 4)
pen = New Pen(Color.Blue)
pen.Alignment = PenAlignment.Inset
e.Graphics.DrawRectangle(pen, insideRect)


.



Relevant Pages

  • Re: What property defines a controls paint bounds?
    ... And you need to subtract one from the width and height to get the whole rectangle to draw. ... A line drawn from to for example will fill all of the pixels just to the right of that 0-width vertical line between those coordinates, inclusive. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Background color of rectangle
    ... rectangle around the text. ... (actualy I draw two rectangles and a few vertical ... >>> drawing the string. ... >>> Dim measureStringGraphics As Graphics ...
    (microsoft.public.dotnet.languages.vb)
  • RE: GDI+ Clip Region allows 0.0f width pen to draw through
    ... Just to make this more outrageous if you draw the vertical lines from the ... I took the previous code I posted and made the panel anchor to all four ... private void panel1_SizeChanged ... In other words create a rectangle that is a wider than the panel. ...
    (microsoft.public.win32.programmer.gdi)
  • Re: Horizontal lines
    ... Now I'm trying to draw a horizontal line in code. ... rectangle "separating" the opportunities, ... Dim intPageHeadHeight As Integer ... >> Dim intPageHeadHeight As Integer ...
    (microsoft.public.access.reports)
  • Re: My earlier post was Horizontal Line
    ... The code below is the exact of my Report module. ... It can draw the table ... starting point for the line or rectangle. ... QBColor function to specify the color. ...
    (microsoft.public.access.formscoding)