Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2007 May : Bug in DrawTextExW ?
| Subject: | Bug in DrawTextExW ? |
| Posted by: | "Der§en" (dergen.derg..@gmail.com) |
| Date: | Mon, 14 May 2007 14:44:48 |
Why this routine calculation not all the time the good height, in 90% of the
cases the value is good but not in all the case, is this a bug of the
function or my call is incorrect?
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function GetCellTextSize(N: TDBGrid; ACol, ARow: Integer): TSize;
var
r: TRect;
ws: widestring;
Params: TDrawTextParams;
begin
ws := N.Cells[ACol, ARow];
r := N.GetCellRect(ACol, ARow);
with Params do
begin
Cbsize := SizeOf(DrawTextParams);
iTabLength := 0;
iLeftMargin := 2;
iRightMargin := 8;
uiLengthDrawn := Length(s);
end;
DrawTextExW(N.Canvas.Handle, PWidechar(ws), -1, r, DT_LEFT or DT_WORDBREAK
or DT_NOPREFIX or DT_CALCRECT or DT_NOCLIP, @params);
Result.cy := (r.Bottom - r.Top);
if (Result.cy < N.RowSize) then
Result.cy := N.RowSize;
Result.cx := (r.Right - r.Left);
end;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Dergen.