Another example of using the HTML Component Library.
Visual part is bult with only one line of Delphi code (OnElementClick event).
Two HTML Panels - one for the map and one for selected symbol.
Map creation procedure:
procedure TCharForm.CreateCharMap(const FontName: string);
var GS: PGlyphSet;
i, k, rowsize, rowindex, rowcount: integer;
R: PWCRange;
B: TBitmap;
s, xchar, hintclass: string;
begin
s:='
';
B:=TBitmap.Create;
try
B.Canvas.Font.Name:=FontName;
k := GetFontUnicodeRanges(B.Canvas.Handle, nil);
GetMem(Pointer(GS), k);
try
GS.cbThis:=k;
GS.flAccel:=0;
GS.cGlyphsSupported:=0;
if GetFontUnicodeRanges(B.Canvas.Handle, GS)<>0 then begin
rowindex:=0;
rowsize:=20;
rowcount:=0;
R :=@GS.ranges[0];
hintclass:='hint--bottom';
for i:=0 to GS.cRanges-1 do begin
for k:=0 to R.cGlyphs-1 do begin
if rowindex>rowsize then begin
s:=s+'
';
rowindex:=0;
inc(rowcount);
if rowcount>3 then hintclass:='hint--top';
end;
if ord(R.wcLow)+k>32 then begin
xchar:=''+inttostr(ord(R.wcLow)+k)+';';
s:=s+Format('%s | ', [hintclass, xchar, xchar]);
inc(rowindex);
end;
end;
inc(R)
end;
end;
finally
FreeMem(pointer(GS));
end;
finally
B.Free;
end;
HtPanel1.HTML.Text:=s+'
';;
HtPanel1.Doc.Recalc;
end;
James Foster
ReplyDeleteYes, http://delphihtmlcomponents.com/charmaposx.png
Thank you Alexander Sviridenkov Can HTML Components library use custom fonts loaded from a resource/file (not installed on the OS)?
ReplyDeleteJames Foster
ReplyDeleteOn Windows - yes