unit MessageUnit;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Buttons, StdCtrls, ExtCtrls;

type
  TfrmMessage = class(TForm)
    sbNoIcon: TSpeedButton;
    Label1: TLabel;
    sbWarning: TSpeedButton;
    sbInfo: TSpeedButton;
    sbStop: TSpeedButton;
    sbQuest: TSpeedButton;
    rgType: TRadioGroup;
    txtMessage: TEdit;
    Label2: TLabel;
    Label3: TLabel;
    cmdSend: TButton;
    cmdCancel: TButton;
    cmdTest: TButton;
    Label4: TLabel;
    txtCaption: TEdit;
    procedure FormCreate(Sender: TObject);
    procedure sbNoIconClick(Sender: TObject);
    procedure sbWarningClick(Sender: TObject);
    procedure sbInfoClick(Sender: TObject);
    procedure sbStopClick(Sender: TObject);
    procedure sbQuestClick(Sender: TObject);
    procedure cmdTestClick(Sender: TObject);
    procedure cmdCancelClick(Sender: TObject);
    procedure cmdSendClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmMessage: TfrmMessage;
implementation

uses main;

 var
  CIcon : integer;
  IconConst : array [0..4] of integer=(0, MB_ICONEXCLAMATION,
         MB_ICONINFORMATION, MB_ICONSTOP,  MB_ICONQUESTION);
{$R *.DFM}

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

procedure TfrmMessage.sbNoIconClick(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.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.cmdCancelClick(Sender: TObject);
begin
 frmMessage.Close;
end;

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

end.
