ayuda

Please discuss general Delphi programming topics here.

ayuda

Postby jfer » July 18th, 2007, 11:32 pm

:D 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.
jfer
Member
Member
 
Posts: 2
Joined: July 18th, 2007, 10:57 pm
Location: argentina

Postby Kambiz » July 22nd, 2007, 9:15 am

Code: Select all
GetGlyphIndices(DC, PChar(EllipsisSingle), 1, @GlyphIndex, GGI_MARK_NONEXISTING_GLYPHS);
if GlyphIndex = $FFFF then
  Ellipsis := @EllipsisTriple
else
  Ellipsis := @EllipsisSingle;

The above code is used to check whether the selected font has the glyph for the ellipsis character (as a single character) or not. When the single character ellipsis is missing in the font, three period characters denote the ellipsis.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm


Return to Delphi Programming

Who is online

Users browsing this forum: Bing [Bot] and 11 guests

cron