Hello to all, I am new here.
It was revising part of the simplegrah code and a sentence that had never used it, appeared and he/she wanted to see if somebody can help me and to explain like it is used and that he/she makes this instruction.
GetGlyphIndices(DC, PChar(EllipsisSingle), 1, @GlyphIndex, GGI_MARK_NONEXISTING_GLYPHS);
if GlyphIndex = $FFFF then
Ellipsis := @EllipsisTriple
else
Ellipsis := @EllipsisSingle;
This saw it in this function.
function MinimizeText(Canvas: TCanvas; const Text: String; const Rect: TRect): String;
const
EllipsisSingle: String = '…';
EllipsisTriple: String = '...';
var
DC: HDC;
S, E: PChar;
TextExtent: TSize;
TextHeight: Integer;
LastLine: String;
Ellipsis: PString;
MaxWidth, MaxHeight: Integer;
GlyphIndex: WORD;
begin
MaxWidth := Rect.Right - Rect.Left;
MaxHeight := Rect.Bottom - Rect.Top;
Result := WrapText(Canvas, Text, MaxWidth);
DC := Canvas.Handle;
TextHeight := 0;
S := PChar(Result);
while S^ <> #0 do
begin
E := S;
while not (E^ in [#0, #13, #10]) do
Inc(E);
if E > S then
GetTextExtentPoint32(DC, S, E - S, TextExtent)
else
GetTextExtentPoint32(DC, ' ', 1, TextExtent);
Inc(TextHeight, TextExtent.CY);
if TextHeight <= MaxHeight then
begin
S := E;
if S^ <> #0 then
begin
Inc(S);
if (S^ <> (S - 1)^) and (S^ in [#13, #10]) then
Inc(S);
end;
end
else
begin
repeat
Dec(S);
until (S < PChar(Result)) or not (S^ in [#13, #10]);
SetLength(Result, S - PChar(Result) + 1);
if S >= PChar(Result) then
begin
E := StrEnd(PChar(Result));
S := E;
repeat
Dec(S)
until (S < PChar(Result)) or (S^ in [#13, #10]);
SetString(LastLine, S + 1, E - S - 1);
SetLength(Result, S - PChar(Result) + 1);
GetGlyphIndices(DC, PChar(EllipsisSingle), 1, @GlyphIndex, GGI_MARK_NONEXISTING_GLYPHS);
if GlyphIndex = $FFFF then
Ellipsis := @EllipsisTriple
else
Ellipsis := @EllipsisSingle;
LastLine := LastLine + Ellipsis^;
GetTextExtentPoint32(DC, PChar(LastLine), Length(LastLine), TextExtent);
while (TextExtent.CX > MaxWidth) and (Length(LastLine) > Length(Ellipsis^)) do
begin
Delete(LastLine, Length(LastLine) - Length(Ellipsis^), 1);
GetTextExtentPoint32(DC, PChar(LastLine), Length(LastLine), TextExtent);
end;
Result := Result + LastLine;
end;
Break;
end;
end;
end;
Thank you from already.