Graphics.Drawstring

Someone please explain this: The X parameter specifies the distance from the left of the Graphics object in pixels.

Left of the Graphics object to … where. margin?

the left
position 0
no consideration for “margin”

Excuse me if I misunderstood you, Jim, but it occurs to me you might have a confusion about the graphics object. That’s not an object that contains an image, but the virtual canvas you are painting on in a Canvas Paint or Listbox DrawBackground event. Hence, as Norman said, no margin. It does not exist on screen. When you’re done, the graphics information will be rendered to pixels by the system and the result is drawn on the screen at the position of the control it belongs to.

The graphic object does not have a margin. If you want one, you can create a clip to draw within a new graphic object inside. See http://documentation.xojo.com/index.php/Graphics.Clip

If you’re referring to printing, 0 in the graphics object is the margin, not the edge of the paper.

also be aware of TEXTASCENT and TEXTHEIGHT values

If you want the BASELINE of a character to be at coordinate X,Y
you dont use

g.DrawString "AbcXyZ",x,y

you would use

g.DrawString "AbcXyZ",x,y+g.TextAscent

the first example puts the top/left corner of the bounding rectangle at X,Y
the second puts the baseline at X,Y
for approximate (see other topics discussing stringheight), you would increase Y by g.textheight for “the next line”

The Y parameter to DrawString is the Baseline, not the top/left corner.

Thanks. This is helping me understand graphics better.