mainform.pas

来自「Delphi Kylix Database Development 附书代码」· PAS 代码 · 共 61 行

PAS
61
字号
unit MainForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, ComCtrls;

const
  UM_CONNECT = WM_USER + 101;

type
  TfrmMain = class(TForm)
    StatusBar1: TStatusBar;
    pnlConnections: TPanel;
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
    FConnections: Integer;
    procedure UMConnect(var Msg: TMessage); message UM_CONNECT;
  public
    { Public declarations }
  end;

var
  frmMain: TfrmMain;

implementation

resourcestring
 SOneConnection = '1 Connection';
 SConnections   = '%d Connections';

 SHeapAllocated = '%s bytes allocated';
 
{$R *.dfm}

{ TfrmMain }

procedure TfrmMain.UMConnect(var Msg: TMessage);
begin
  Inc(FConnections, Msg.WParam);
  if FConnections = 1 then
    pnlConnections.Caption := SOneConnection
  else
    pnlConnections.Caption := Format(SConnections, [FConnections]);
end;

procedure TfrmMain.Timer1Timer(Sender: TObject);
var
  HS: THeapStatus;
begin
  HS := GetHeapStatus;

  StatusBar1.SimpleText := Format(SHeapAllocated,
    [FloatToStrF(HS.TotalAllocated, ffNumber, 10, 0)]);
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?