Author: Jonas Bilinkevicius
I'd like to insert enough spaces between two strings to make a caption for a
titlebar show the pieces justified left and right. For example, program name on the
left and copyright notice on the right.
Answer:
The DrawText API function supports drawing justified text. Below is an example:
1 { ... }2 var3 R: TRect;
4 fmt: UINT;
5 begin6 R := ClientRect; {define your rectangle to draw the text}7 with Canvas do{canvas to paint on}8 begin9 fmt := DT_LEFT;
10 DrawText(Handle, PChar(LeftSide), Length(LeftSide), R, fmt);
11 fmt := DT_RIGHT;
12 DrawText(Handle, PChar(RightSide), Length(RightSide), R, fmt);
13 end;
14 end;