Paul
2003-07-30 12:46:29 UTC
Tested: DrawText, DrawTextEx
When I call DrawText with DT_CALCRECT and then normal DrawText to
output some text, there is a problem with allignment. No matter if I
set alligment to the RIGHT, it is always drawn in the TOP LEFT corner
of a cell.
What's the problem?
Yes and, when I simply delete the line with W:= DrawTextEx... on which
I can obtain the height of the cell... then everything's perfect (but
the Multiline mode does not work, obviously)
Take a look:
Flag:= DT_NOPREFIX or DT_MODIFYSTRING or DT_END_ELLIPSIS;
if saiRightAlign in sas then Flag := Flag or DT_RIGHT else
Flag := Flag or DT_LEFT;
if FMultiLineCells and not Fixed then
begin
Flag := Flag or DT_WORDBREAK or DT_WORD_ELLIPSIS or DT_TOP;
W := DrawTextEx(Canvas.Handle,PChar(S),-1,Rect, Flag or DT_CALCRECT,
nil);
Inc(W, 4);
if (RowHeights[ARow] < W) then
RowHeights[ARow]:= W;
end else
begin
Flag := Flag or DT_SINGLELINE or DT_VCENTER;
Rect:= dRect(Rect, 2,0,-2,0);
end;
DrawTextEx(Canvas.Handle,PChar(S),-1,Rect, Flag, nil);
When I call DrawText with DT_CALCRECT and then normal DrawText to
output some text, there is a problem with allignment. No matter if I
set alligment to the RIGHT, it is always drawn in the TOP LEFT corner
of a cell.
What's the problem?
Yes and, when I simply delete the line with W:= DrawTextEx... on which
I can obtain the height of the cell... then everything's perfect (but
the Multiline mode does not work, obviously)
Take a look:
Flag:= DT_NOPREFIX or DT_MODIFYSTRING or DT_END_ELLIPSIS;
if saiRightAlign in sas then Flag := Flag or DT_RIGHT else
Flag := Flag or DT_LEFT;
if FMultiLineCells and not Fixed then
begin
Flag := Flag or DT_WORDBREAK or DT_WORD_ELLIPSIS or DT_TOP;
W := DrawTextEx(Canvas.Handle,PChar(S),-1,Rect, Flag or DT_CALCRECT,
nil);
Inc(W, 4);
if (RowHeights[ARow] < W) then
RowHeights[ARow]:= W;
end else
begin
Flag := Flag or DT_SINGLELINE or DT_VCENTER;
Rect:= dRect(Rect, 2,0,-2,0);
end;
DrawTextEx(Canvas.Handle,PChar(S),-1,Rect, Flag, nil);