unit TestFrm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Timer,

  IniObj, FoldrDlg, Mask, LineConnector, BtnEdit ,
  CommInt ,
  FileMenuHdl ,
  BomeOneInstance ,
  PBBinHexEdit ,
  PBSpinEdit ,
  AlRep ,
  extcomdl ,
  {strgrdex ,}
  ulanlibu ,
  OneEditPanel ,
  ULRecTyp ,
  stru ,
  XStringGridRegister ,
  XStringGrid ,
  XSAbout ,
  CECheckList ,
  CEForm ,
  CEFormRegister ,
  CEButton ,
  ValuePanel ,
  ULObjCtrl ,

  PBSystem, PropUtl, {MikroToAAAu, }SubClasser, LogFrm,
  Language;

type
  TTestForm2 = class(TForm)
    TestStreamButton: TButton;
    ResultEdit: TEdit;
    Button1: TButton;
    Button2: TButton;
    BtnEdit1: TBtnEdit;
    BtnEdit2: TBtnEdit;
    FolderDialog1: TFolderDialog;
    Button3: TButton;
    DirEdit: TEdit;
    Button4: TButton;
    PBSystemMemo: TMemo;
    Button5: TButton;
    LineConnector1: TLineConnector;
    LineConnector2: TLineConnector;
    MaskEdit: TMaskEdit;
    MaskEditMaskEdit: TEdit;
    MaskEditTextEdit: TEdit;
    procedure TestStreamButtonClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure MaskEditMaskEditChange(Sender: TObject);
    procedure MaskEditChange(Sender: TObject);
  private
    { Private declarations }
    {FULGrid: TULStringGrid;}
    FInfo:longint;
    FBtnEdit: TBtnEdit;
    FLineConnector: TLineConnector;
    {FSubClasser: TSubClasser;}
  protected
    procedure WndProc(var Message: TMessage); override;
  public
    { Public declarations }
  end;

var
  TestForm2: TTestForm2;

implementation

{$R *.DFM}

procedure TTestForm2.TestStreamButtonClick(Sender: TObject);
var
  s:TMemoryStream;
  v, l:longint;
  starttime, writetime, streamtime, memtime:longint;
  cr:TCursor;
  size:longint;
const
  testcount = 1000000;
begin
  cr := Screen.Cursor;
  Screen.Cursor := crHourGlass;
  try

  s := TMemoryStream.Create;
  v := 0;
  starttime := mstime;
  for l := 0 to testcount - 1 do begin
    s.WriteBuffer(v, sizeof(v));
  end;
  writetime := mstime - starttime;

  s.Position := 0;
  starttime := mstime;
  for l := 0 to testcount - 1 do begin
    s.ReadBuffer(v, sizeof(v));
  end;
  streamtime := mstime - starttime;
  starttime := mstime;
  size := s.Size;
  for l := 0 to testcount - 1 do begin {tmemorystream}
    if l + sizeof(v) < size then begin
      if s is TMemoryStream then
        v := PByteArray(s.Memory)^[l * sizeof(v)];
    end;
  end;
  memtime := mstime - starttime;
  ResultEdit.Text := IntToStr(writetime) + ' ' + IntToStr(streamtime) + ' ' + IntToStr(memtime);
  finally
    Screen.Cursor := cr;
  end;
end;

procedure TTestForm2.FormCreate(Sender: TObject);
{var f: TULFObj;
  Ulfobju}
var
  l: TLanguage;
begin
{  f := TULFObj.Load('ULD.ULD');
  CurULObj := f.FindOrAdd(ULDID, '');
  FULGrid := TULStringGrid.Create(Self);
  FULGrid.Parent := Self;}

  FBtnEdit := TBtnEdit.Create(Self);
  FBtnEdit.Parent := Self;
  FBtnEdit.OnBtnClick := Button1Click;

  FLineConnector := TLineConnector.Create(Self);
  FLineConnector.Parent := Self;
  FLineConnector.Source := DirEdit;
  FLineConnector.Dest := Button5; {tbrush}

  {ResultEdit.Caption := 'x';}
{  FSubClasser := TSubClasser.Create(Self);
  FSubClasser.SubClass;
  FSubClasser.SubClassMode := smOn;{ smOnce;}
  l := TLanguage.Create(Self);
  l.RegisterMode := true;
  l.Check;
end;

procedure TTestForm2.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  FInfo := 0;
end;

procedure TTestForm2.WndProc(var Message: TMessage);
begin
  case Message.Msg of
    WM_LBUTTONDOWN: begin
      FInfo := 0;
    end;
    WM_HSCROLL: begin
      FInfo := 0;
    end;
    WM_VSCROLL: begin
      FInfo := 0;
    end;
    WM_SYSCOMMAND: begin
      FInfo := 0;
    end;
  end;{ messages }
  inherited;
end;

procedure TTestForm2.Button1Click(Sender: TObject);
begin
  LogForm.Show;
  LogForm.Log(TComponent(Sender).Name);
end;

procedure TTestForm2.Button2Click(Sender: TObject);
begin
{  UserMode := TUserMode(not boolean(UserMode));
  if UserMode = umUser then
    Button2.Caption := 'Set SysOp Mode'
  else
    Button2.Caption := 'Set User Mode';}
end;

procedure TTestForm2.Button3Click(Sender: TObject);
begin
  FolderDialog1.Directory := DirEdit.Text;
  if FolderDialog1.Execute then
    DirEdit.Text := FolderDialog1.Directory;{SelectionPath;}
end;

procedure TTestForm2.Button4Click(Sender: TObject);
var
  i: integer;
  n: shortstring;
  v: AnsiString;
  pb: TPBSystemPath;
begin
  pb := TPBSystemPath.Create(nil);
  i := 0;
  PBSystemMemo.Lines.Clear;
  while ClassGetPropNameAndValue(pb, i, n, v) do begin
    PBSystemMemo.Lines.Add(n + '=' + v);
    inc(i);
  end;
  pb.Free;
end;
{tcontrol tedit}
procedure TTestForm2.Button5Click(Sender: TObject);
begin
{  MicroToAAA('c:\mikro\prog\', 'd:\ulan\data\programs\');}
end;

procedure TTestForm2.MaskEditMaskEditChange(Sender: TObject);
begin
  MaskEdit.EditMask := MaskEditMaskEdit.Text;
end;

procedure TTestForm2.MaskEditChange(Sender: TObject);
begin
  MaskEditTextEdit.Text := MaskEdit.Text;
end;{exelogu ulobju spectrum}

end.
