I am drawing a dashed li开发者_高级运维ne on the TImage Canvas and found out that the size of dashes is way too big for the drawing area. Is there a way to change the size of dashes of lines drawn on canvas?
This is what i do to be able to draw dashed lines.Canvas.Pen.Style := psDash;
Canvas.Polyline(myPoints);
And i didn't find any Pen property which could change the dash size/length.
Thanks
According to http://docwiki.embarcadero.com/VCL/e/index.php/Graphics.TPenStyle you can use psUserStyle
The docs for ExtCreatePen are at http://msdn.microsoft.com/en-us/library/dd162705(VS.85).aspx
Here's my interpretation of how ExtCreatePen is meant to be used in combination with TPen:
const
NumberOfSections = 8;
LineLengths: array[0..NumberOfSections-1] of DWORD =
(20, 15, 14, 17, 14, 8, 16, 9);
var
logBrush: TLogBrush;
begin
logBrush.lbStyle := BS_SOLID;
logBrush.lbColor := DIB_RGB_COLORS;
logBrush.lbHatch := HS_BDIAGONAL; // ignored
Canvas.Pen.Handle := ExtCreatePen(PS_GEOMETRIC or PS_USERSTYLE or PS_ENDCAP_ROUND or PS_JOIN_BEVEL,
4, logBrush, NumberOfSections, @LineLengths[0]);
// now Canvas.Pen.Style = psUserStyle
Canvas.Polyline([Point(0,0), Point(100,100), Point(200, 100)]);
end;
I don't know, but, which is the implementation of Polyline()? When you control+click it, which code do you see? Is it using an property-exposed variable may be? If so, you can set it, otherwise -if it is hardcoded- you will see it, and know that you can't.
精彩评论