Recent

Author Topic: [SOLVED] How to calculate numbers of chars in statusbar1as dfm ?  (Read 368 times)

d2010

  • Jr. Member
  • **
  • Posts: 65
[SOLVED] How to calculate numbers of chars in statusbar1as dfm ?
« on: November 21, 2024, 01:44:39 pm »
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
« Last Edit: December 06, 2024, 09:48:23 pm by d2010 »

d2010

  • Jr. Member
  • **
  • Posts: 65
Re: MainForm .Lfm statusbar1; how to calculate numbers of chars?
« Reply #1 on: December 06, 2024, 09:47:16 pm »
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 enougg, the my solution.
« Last Edit: December 06, 2024, 09:51:21 pm by d2010 »

 

TinyPortal © 2005-2018