Esa imagen que pones tiene toda la pinta de ser un JFControls, un grid muy tuneable. Son componentes de pago.
Buscando por mis bibliotecas he encontrado una forma "fácil" de usar el método de
fjcg02. Copia todo en una nueva unidad y ponle el nombre lpCanvas.pas:
Código Delphi
[-]
unit lpCanvas;
interface
uses Graphics,windows;
type TAlignText = (atTopLeft=0, atTopCenter, atTopRight,
atCenterLeft, atCenter, atCenterRight,
atBottomLeft, atBottomCenter, atBottomRight);
procedure PaintText(ACanvas: TCanvas; const ARect: TRect;
const Line:string; Align:TAlignText;
const FillBackground:Boolean = false);
implementation
uses sysutils;
const
Offset = 2;
procedure PaintText(ACanvas: TCanvas; const ARect: TRect;
const Line:string; Align:TAlignText;
const FillBackground:Boolean = false);
var x,y,CenterX, CenterY:integer;
Options :integer;
S: array[0..255] of Char;
begin
Options := ETO_CLIPPED;
if FillBackground then
Options := options or ETO_OPAQUE;
with ARect, Acanvas do
begin
CenterY := (Bottom - Top - TextHeight(Line)) div 2;
CenterX := (Right - Left - TextWidth(line)) div 2;
x:= Offset;
y:= Offset;
case Align of
atTopLeft :begin
x := left + Offset ;
end;
atTopCenter :begin
x := left + CenterX;
end;
atTopRight :begin
x := Right - Offset - TextWidth(Line);
end;
atCenterLeft :begin
x:= Left+ Offset;
y:= CenterY;
end;
atCenter :begin
x:= CenterX;
y:= CenterY;
end;
atCenterRight :begin
x:= Right - Textwidth(line) - Offset;
y:= CenterY;
end;
atBottomleft :begin
y:= Bottom - Textheight(Line) - Offset;
end;
atBottomCenter :begin
x:= CenterX;
y:= Bottom - Offset - Textheight(Line);
end;
atBottomRight :begin
x:= Right - TextWidth(line) - Offset;
y:= Bottom - Textheight(Line)-Offset;
end;
end;
ExtTextOut(Handle, x, y, options,@ARect, StrPCopy(S,Line),length(line),nil);
end;
end;
end.
Forma de uso:
Código Delphi
[-]
uses lpCanvas;
PaintText(Canvas, Rect, 'Mi texto Linea1', atTopLeft,
true);
PaintText(Canvas, Rect, 'Mi texto Linea 2', atBottomRight, False);
Como ves tienes 9 formas de alinear texto dentro de la celda, más que suficiente
.
Saludos