unit Unit8;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  TFlatButtonUnit, ExtCtrls, TFlatPanelUnit, TFlatHintUnit, StdCtrls,
  TFlatSpeedButtonUnit, TFlatEditUnit, BUFormAnimation;

type
  TfrmMessage = class(TForm)
    FlatPanel1: TFlatPanel;
    FlatButton1: TFlatButton;
    FlatButton2: TFlatButton;
    FlatPanel2: TFlatPanel;
    txtCaption: TFlatEdit;
    txtMessage: TFlatEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    sbNoIcon: TFlatSpeedButton;
    sbWarning: TFlatSpeedButton;
    sbQuest: TFlatSpeedButton;
    sbStop: TFlatSpeedButton;
    sbInfo: TFlatSpeedButton;
    rgType: TRadioGroup;
    FlatHint1: TFlatHint;
    cmdTest: TFlatButton;
    cmdSend: TFlatButton;
    FlatButton5: TFlatButton;
    BUFormAnimation1: TBUFormAnimation;
    procedure FlatButton1Click(Sender: TObject);
    procedure FlatButton2Click(Sender: TObject);
    procedure FlatPanel1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FlatButton5Click(Sender: TObject);
    procedure cmdTestClick(Sender: TObject);
    procedure cmdSendClick(Sender: TObject);
    procedure sbNoIconClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure sbWarningClick(Sender: TObject);
    procedure sbInfoClick(Sender: TObject);
    procedure sbStopClick(Sender: TObject);
    procedure sbQuestClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmMessage: TfrmMessage;
  CIcon : integer;
  IconConst : array [0..4] of integer=(0, MB_ICONEXCLAMATION,
         MB_ICONINFORMATION, MB_ICONSTOP,  MB_ICONQUESTION);
         
implementation

uses Unit1;

{$R *.DFM}

procedure TfrmMessage.FlatButton1Click(Sender: TObject);
begin
frmMessage.close;
end;

procedure TfrmMessage.FlatButton2Click(Sender: TObject);
begin
frmMessage.WindowState:=wsMinimized;
end;

procedure TfrmMessage.FlatPanel1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
 Perform(WM_NCLBUTTONDOWN,HTCAPTION,0);
end;

procedure TfrmMessage.FlatButton5Click(Sender: TObject);
begin
frmMessage.close;
end;

procedure TfrmMessage.cmdTestClick(Sender: TObject);
var TSum : LongInt;
     MCapt, MText : PChar;
     MT, RT : string;
     i : integer;
begin
 TSum:=0;
 case rgType.ItemIndex of
  1 : TSum:=MB_ABORTRETRYIGNORE;
  2 : TSum:=MB_OKCANCEL;
  3 : TSum:=MB_RETRYCANCEL;
  4 : TSum:=MB_YESNO;
  5 : TSum:=MB_YESNOCANCEL;
 end;
 TSum:=TSum+IconConst[CIcon];
 getMem (MCapt, 100);
 StrPCopy (MCapt, txtCaption.Text);
 RT:='';
 MT:=txtMessage.Text;
 for i:=1 to Length (MT) do
  if MT[i]='|' then RT:=RT+chr(13)+chr(10) else RT:=RT+MT[i];
 getMem (MText, 500);
 StrPCopy (MText, RT);
 MessageBox (frmMessage.Handle, MText, MCapt, TSum);
 freeMem (MText);
 freeMem (MCapt);
end;

procedure TfrmMessage.cmdSendClick(Sender: TObject);
var MT : string;
begin
 MT:='{MSG}'+txtCaption.Text+
      '$$$'+txtMessage.Text+
      '%%%'+inttostr(rgType.ItemIndex)+inttostr(CIcon);
 frmClient.Client.SendStr (MT);
 frmMessage.Close;
end;

procedure TfrmMessage.sbNoIconClick(Sender: TObject);
begin
CIcon:=0;
end;

procedure TfrmMessage.FormCreate(Sender: TObject);
begin
CIcon:=0;
end;

procedure TfrmMessage.sbWarningClick(Sender: TObject);
begin
CIcon:=1;
end;

procedure TfrmMessage.sbInfoClick(Sender: TObject);
begin
CICon:=2;
end;

procedure TfrmMessage.sbStopClick(Sender: TObject);
begin
 CIcon:=3;
end;

procedure TfrmMessage.sbQuestClick(Sender: TObject);
begin
CIcon:=4;
end;

procedure TfrmMessage.FormActivate(Sender: TObject);
begin
BUFormAnimation1.AppearRectangle;
end;

end.
