I am using the WinAPI DrawText to write to the canvas within a Rectangle. I have to write text horizontally and vertically. Using the uFormat constant to set how the text is aligned. I cannot get it to align vertical text to the top of the rectangle. see image
This is the code I am using to draw the text
procedure SetOrientation(pIndex: Integer);
var j: Integer;
begin
f := 0;
j := fPinCount div 4;
if pindex < j then begin
fBuffer.Canvas.font.orientation := 0 ;
f := DT_RIGHT
end else
if pIndex < 2 * j then begin
fBuffer.Canvas.font.Orientation := 900 ;
f := DT_TOP
end else
if pIndex < 3 * j then begin
fBuffer.Canvas.font.orientation := 0;
f := DT_LEFT
end else begin
fBuffer.Canvas.font.Orientation := 900;
f := DT_LEFT;
f := f or DT_SINGLELINE or DT_NOCLIP;
end;
SetOrientation(i);
DrawText(FBuffer.Canvas.Handle, s, Length(s), PinDscRects[i], f);
fBuffer.Canvas.Font.Orientation := 0;
I have tried all values of uFormat but none will justify the vertical text. Can you suggest an alternative method?
