[SOLVED] How to calculate numbers of chars in statusbar1as dfm ? lazarus / 34-Windows ---------------------------------------------------------------------- d2010 · 2024-11-21 12:44 Hello. C:Q1= How to calculate numbers of chars , visible on mainform? If you count 0..9 at Nae-Lshort, them  you got 63..78digits or letters. But myprograme.exe cannot got the numbers 63digits , form the left to the right of kMainForm.lfm The String Nae-Lshort12345678901234567890 .... 0 is StatusBar1.Text  :oII recovery very old source.pas, Code: [Select]function GetAveCharSize2(Canvas: TCanvas): TPoint; var   I: Integer;   Buffer: array[0..51] of Char; begin   for I := 0 to 25 do Buffer[I] := Chr(I + Ord('A'));   for I := 0 to 25 do Buffer[I + 26] := Chr(I + Ord('a'));   GetTextExtentPoint(Canvas.Handle, Buffer, 52, TSize(Result));   Result.X := Result.X div 52; end; Otherwise, how to calculate GetAveCharSize2  as count-of-char/s with  StatusBar1.FontSize? Maybe GetAveCharSize2 is very wrong,; please other function? Thank/s ---------------------------------------------------------------------- d2010 · 2024-12-06 20:47 Here is my solution. Code: [Select]function ansi_str_AveCharSize(TCanvas_Han:THandle;const Sir:string;out xwi,yei:integer):Boolean; var coo:windows.tpoint; begin   coo.x :=00; result:=false;   coo.y :=00; if (length(sir)<01) then exit;   if (GetTextExtentPoint(TCanvas_Han,pchar(sir),length(sir), TSize(coo)))and(coo.x>0)and(coo.y>00) then     Begin xwi:=coo.x;           yei:=coo.y;          result:=true;      End; end;//off-GetAveCharSize3 procedure TMainForm.FormResize(Sender: TObject); Var x1c,x2c,ync:integer; Const bif23:array[false..true] of integer=(3,2); begin     x1c :=00;     x2c :=00;     ync :=00;        if (Ansi_str_AveCharSize(StatusBar1.Canvas.Handle,'A',x1c,ync))  and (ync>00) and        (Ansi_str_AveCharSize(StatusBar1.Canvas.Handle,' ',x2c,ync)) and (x2c>00)         then            Begin rStatusBar1CountVisibleChar:=Width div (x1c+x2c);                  if (rStatusBar1CountVisibleChar<00) then  rStatusBar1CountVisibleChar:=000 else                  if (rStatusBar1CountVisibleChar>255) then rStatusBar1CountVisibleChar:=255;  //Rugăciunea pe care Arsenie Boca o rostea în fiecare seară.mp4            End;      Listlog1.Height:=Height div 03; End;// div bif23[height>444]; Anyone, have other opinion? Other method. Is good enough, the my solution.