>The following code segment should generate the symbol "X";
>
> Form2.Canvas.MoveTo(97,103);
> Form2.Canvas.LineTo(103,97);
> Form2.Canvas.MoveTo(97,97);
> Form2.Canvas.Lineto(103,103);
>
>That is it should be a symmetrical "X" centered at screen coordinates
>(100,100) for screens with an aspect ratio of 1.0.
>
>But, it does not
I assume that your problem is that you are getting an unsymmetrical
"X".
All versions of Windows and of Delphi should get this, not just NT
and
Delphi 3.01. This isn't a "bug", but rather a poorly documented
feature.
Windows' graphics has this non-obvious feature that you have stumbled
over.
Most drawing commands that have boundaries defined by two points (such
as
LineTo [defined by the current point and the point referred to by the
parameters], Rectangle and FillRect [defined by the parameters] have
this
'feature'. The resulting drawing indeed starts at the starting
point, but
does not reach all the way to the ending point. IOW, when drawing
a line,
the visible line does start at the starting point, but the pixel at
the
ending point is *not* drawn. When drawing a rectangle, the visible
rectangle "includes the left and top borders, but excludes the right
and
bottom borders of the [defined] rectangle." (The last quote is
from the
Win32.hlp entry for FillRect.)
So, although the points (103,97) and (103,103) are referred to in your
code,
the pixels at those positions are not drawn. To draw them, either
continue
the lines a little farther, or specifically draw those points with
the
Pixels[] property. Here's the first way:
Form1.Canvas.MoveTo(97,103);
Form1.Canvas.LineTo(103+1,97-1);
Form1.Canvas.MoveTo(97,97);
Form1.Canvas.Lineto(103+1,103+1);
Here's the second:
Form1.Canvas.MoveTo(97,103);
Form1.Canvas.LineTo(103,97);
Form1.Canvas.Pixels[103,97] := Form1.Canvas.Pen.Color;
Form1.Canvas.MoveTo(97,97);
Form1.Canvas.Lineto(103,103);
Form1.Canvas.Pixels[103,103] := Form1.Canvas.Pen.Color;
This Windows "feature" does have some advantages in graphics programming,
but you have stumbled over one of the disadvantages. To make
things worse,
Windows is not fully consistent in this. Some functions *do*
include the
ending/lower-right point (but I can't remember which ones right now).