⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usendmsg.pas

📁 一个采用delphi开的数库系统
💻 PAS
字号:
unit UsendMsg;

interface

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

type
  TfrmSendMsg = class(TForm)
    GroupBox1: TGroupBox;
    Panel1: TPanel;
    Label1: TLabel;
    AddrBox: TComboBox;
    bbtnSend: TBitBtn;
    GroupBox2: TGroupBox;
    mesText: TMemo;
    StatusPanel: TPanel;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure bbtnSendClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure AddrBoxChange(Sender: TObject);
    procedure mesTextChange(Sender: TObject);
  private
    { Private declarations }
     UserName:String;
     MessageHeader:TStringList;
  public
    { Public declarations }
  end;

var
  frmSendMsg: TfrmSendMsg;

implementation

{$R *.dfm}

procedure TfrmSendMsg.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action:=caFree;
end;

procedure TfrmSendMsg.bbtnSendClick(Sender: TObject);
var
 i,res:Integer;
begin
  if AddrBox.Text<>'' then
   begin
     StatusPanel.Font.Color:=clBlack;
     StatusPanel.Caption:='请稍等......';
     Update;
     if AddrBox.Items.IndexOf(AddrBox.Text)=-1 then
      AddrBox.Items.Add(AddrBox.Text);
     res:=SendMsg(AddrBox.Text,'',MessageHeader.Text+mesText.Text);
     //ShowMessage(IntToStr(res));
     if res=0 then
      begin
       frmSendMsg.StatusPanel.Caption:='消息已成功送出';
       frmSendMsg.StatusPanel.Font.Color:=clBlue;
      end;
     try
      if res=87 then
      begin
       frmSendMsg.StatusPanel.Caption:='指定参数错误';
       frmSendMsg.StatusPanel.Font.Color:=clRed;
      end;
     except
       //ShowMessage('指定参数错误');
     end;
      try
       if res=2273 then
       begin
        frmSendMsg.StatusPanel.Caption:='不能找到该IP:'+AddrBox.Text;
        frmSendMsg.StatusPanel.Font.Color:=clRed;
       end;
       // ShowMessage('不能找到该IP:'+AddrBox.Text);
      except
      end;
      try
        if (res<>0)and(res<>87)and(res<>2273) then
       begin
        frmSendMsg.StatusPanel.Caption:='错误:'+IntToStr(res);
        frmSendMsg.StatusPanel.Font.Color:=clRed;
       end;
     except
     //
     end;
  end;
end;

procedure TfrmSendMsg.FormCreate(Sender: TObject);
var
 strUser:PChar;
 strSize:DWord;
begin
 mesText.Lines.Clear;
 strUser:=StrAlloc(100);
 strSize:=100;
 GetUserName(strUser,strSize);
 UserName:=strUser;
 strDispose(strUser);
 MessageHeader:=TStringList.Create;
 MessageHeader.Add('----------------');
 MessageHeader.Add('   FROM   '+UserName);
 MessageHeader.Add('----------------');
end;

procedure TfrmSendMsg.AddrBoxChange(Sender: TObject);
begin
  StatusPanel.Caption:='';
end;

procedure TfrmSendMsg.mesTextChange(Sender: TObject);
begin
   StatusPanel.Caption:='';
end;

end.

⌨️ 快捷键说明

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