DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: qiaoguoqiang
今日帖子: 0
在线用户: 2
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 xinhua (傻林) ★☆☆☆☆ -
盒子活跃会员
2003/12/24 18:02:49
标题:
这个问题应如何解决 浏览:1460
加入我的收藏
楼主: 在程序检测到有符合条件的记录时,如何向指定IP地址的机子发送一个提示信息,这个信息包含有符合条件的记录;还有就是在服务器有声音提示信息。谢谢了!
----------------------------------------------
愿和所有喜欢DELPHI的人成为朋友!!
作者:
男 bios (阿贡) ★☆☆☆☆ -
盒子中级会员
2003/12/24 18:51:19
1楼: 1)TServerSocket 具体的没作过
2)BOOL MessageBeep(

    UINT uType   // sound type  
   );  
 

Parameters

uType

Specifies the sound type, as identified by an entry in the [sounds] section of the registry. This parameter can be one of the following values: 

Value  Sound
0xFFFFFFFF  Standard beep using the computer speaker
MB_ICONASTERISK  SystemAsterisk
MB_ICONEXCLAMATION  SystemExclamation
MB_ICONHAND  SystemHand
MB_ICONQUESTION  SystemQuestion
MB_OK  SystemDefault
----------------------------------------------
按此在新窗口浏览图片
按此在新窗口浏览图片
作者:
男 xinhua (傻林) ★☆☆☆☆ -
盒子活跃会员
2003/12/25 21:22:47
2楼: 十分感谢。第一个问题能给点什么提示吗???
----------------------------------------------
愿和所有喜欢DELPHI的人成为朋友!!
作者:
男 xinhua (傻林) ★☆☆☆☆ -
盒子活跃会员
2003/12/29 7:55:32
3楼: 兄弟,只有这两种声音吗?还没有其它一些不是系统的声音吗?
----------------------------------------------
愿和所有喜欢DELPHI的人成为朋友!!
作者:
男 bios (阿贡) ★☆☆☆☆ -
盒子中级会员
2003/12/29 18:49:20
4楼: 1)偶对网络 不太熟悉
2)MessageBeep 只能发这点声音!
  要其他声音 要 用声音文件 配合 播放 控件!
----------------------------------------------
按此在新窗口浏览图片
按此在新窗口浏览图片
作者:
男 asklaibao (laibao) ★☆☆☆☆ -
盒子活跃会员
2003/12/30 1:28:25
5楼: 你可以试试自己定义数据包的格式,比如第1、2字节定为命令,后面的定为数据。我在《网页制作评分程序》(呵呵,这是我带的课)中用的就是这个方法,用的控件是TNMUDP,数据库是Access2000,部分代码:
==============================客户端===============================
procedure TForm1.NMUDP1DataReceived(Sender: TComponent;
  NumberBytes: Integer; FromIP: String; Port: Integer);
var
 MyStream: TMemoryStream;
 MyReceiveTxt: String;
 aCmd : TpfCommands;
 TotalMark: integer;
begin
 MsgSended := false;
///////////////////////////////////////////////////////////////
 MyStream := TMemoryStream.Create; {建立流}
 try
  NMUDP1.ReadStream(MyStream);  {接收流}
  MyStream.Read(aCmd, 1);   // read the 1st byte which is a cmd
  if NumberBytes > 1 then
    begin
      SetLength(MyReceiveTxt, NumberBytes-1);   {NumberBytes为接收到的字节数}
      MyStream.Read(MyReceiveTxt[1], NumberBytes -1 );    {读数据}
    end;
 finally
  MyStream.Free;  {释放流}
 end;
///////////////////////////////////////////////////////////////
 case aCmd of
      pfInvalidInfo   : begin
                          GifLogin.Visible := false;
                          BtnLogin.Enabled := true;
                          MessageBox(Handle,'登录信息不正确!', '出错啦...', MB_OK or MB_ICONSTOP);
                        end;
      //pfNewUser       : fNewUser;
      pfHello         : SendMsgToSvr(', pfHello);
      pfUserOk        : ShowPnls(true);
      pfNeedPass      : SendMsgToSvr(edPass.Text, pfUserPass);
      pfNewPassOK     : MessageBox(Handle,'密码已修改!', '操作完成...', MB_OK or MB_ICONEXCLAMATION);
      pfPageNot       : BtnThisPage.Enabled := false;
      pfPageYes       : BtnThisPage.Enabled := true;
      pfSiteNot       : BtnSite.Enabled := false;
      pfSiteYes       : BtnSite.Enabled := true;
      pfAddNot        : BtnAdd.Enabled := true;  // the additional marks are a little bit different from others
      pfAddYes        : BtnAdd.Enabled := false;
      pfHtmURLOK      : begin
                          TotalMark := MTAppear.Value + MTTeches.Value;
                          if MTcbNoTitle.Checked then dec(TotalMark,2);
                          if MTcbName.Checked then dec(TotalMark,1);
                          if MTcbPhoto.Checked then dec(TotalMark,1);
                          if MTcbNotOri.Checked then dec(TotalMark,1);
                          if TotalMark <= 0 then TotalMark := 1;
                          SendMsgToSvr(inttostr(TotalMark), pfHtmMarks);
                        end;  
 {else
   MessageBox(Handle,'服务器出错,请稍后再试!', '出错啦...', MB_OK or MB_ICONSTOP);}
 end;
end;

procedure TForm1.MsgTimerTimer(Sender: TObject);
begin
  MsgTimer.Enabled := MsgSended;
  if MsgSended and not UserAlreadyLogged then begin
    MsgSended := false;
    BtnLogin.Enabled := true;
    GifLogin.Visible := false;
    MessageBox(Handle,'服务器没有响应,请稍后再试!', '出错啦...', MB_OK or MB_ICONSTOP);
  end;
end;

procedure TForm1.NMUDP1InvalidHost(var handled: Boolean);
begin
  MessageBox(Handle,'服务器出错,请稍后再试!', '出错啦...', MB_OK or MB_ICONSTOP);
end;
===================================服务器端============================
procedure TForm1.NMUDP1DataReceived(Sender: TComponent;
  NumberBytes: Integer; FromIP: String; Port: Integer);
var
 MyStream: TMemoryStream;
 MyReceiveTxt: String;
 aCmd : TpfCommands;
 tempItem: TListItem;
 currentt:_SystemTime;
 tempstr: string;
begin
//////////////////receive message//////////////////////////////
 MyStream := TMemoryStream.Create; {建立流}
 try
  NMUDP1.ReadStream(MyStream);  {接收流}
  MyStream.Read(aCmd, 1);   // read the 1st byte which is a cmd
  if NumberBytes > 1 then
    begin
      SetLength(MyReceiveTxt, NumberBytes-1);   {NumberBytes为接收到的字节数}
      MyStream.Read(MyReceiveTxt[1], NumberBytes -1 );    {读数据}
    end;
 finally
  MyStream.Free;  {释放流}
 end;
///////////////////run the command/////////////////////////////
 case aCmd of
      pfUserEmail     : begin
                          with ADOTable2 do
                              if Locate('Email', MyReceiveTxt, []) then begin

                                tempItem := ListView1.Items.Add;
                                tempItem.Caption := MyReceiveTxt;
                                tempItem.SubItems.Add(FromIP);
                                GetLocalTime(CurrentT);
                                tempItem.SubItems.Add(Add0(CurrentT.wHour)+':'+Add0(CurrentT.wMinute));
                                tempItem.SubItems.Add('联机');

                                SendMsgtoC(', pfNeedPass, FromIP);
                              end
                              else SendMsgtoC(', pfInvalidInfo, FromIP);

                        end;
      pfUserPass      : begin
                          {if MyReceiveTxt='000' then begin
                            SendMsgtoC(', pfNewUser, FromIP);
                            exit;
                          end;}
                          with ADOTable2 do
                              if Locate('Email', GetEmail(FromIP), []) then
                                if MyReceiveTxt = FieldByName('Pass').AsString then
                                  SendMsgtoC(', pfUserOk, FromIP)
                                else begin
                                  DeleteClient(FromIP);
                                  SendMsgtoC(', pfInvalidInfo, FromIP);
                                end;
                        end;

      pfBye           : DeleteClient(FromIP);

      pfNewPass       : begin
                          with ADOTable2 do
                            if Locate('Email', GetEmail(FromIP), []) then begin
                              Edit;
                              FieldByName('Pass').AsString := MyReceiveTxt;
                              FieldByName('LastModify').AsString := DateTimeToStr(Now);
                              ADOTable2.Post;
                              SendMsgtoC(', pfNewPassOk, FromIP);
                              exit;
                            end;
                        end;
      pfIsPageMarked  : begin
                         ADOQuery3.Close;
                         ADOQuery3.SQL.Clear;
                         ADOQuery3.SQL.Add(Format(SqlStr1, ['email', 'marks', 'email', GetEmail(FromIP), 'htmurl', MyReceiveTxt]));
                         ADOQuery3.Open;
                         if ADOTable1.FieldByName('htmurl').AsString <> MyReceiveTxt then SendMsgtoC(', pfPageYes, FromIP)
                           else SendMsgtoC(', pfPageNot, FromIP);
                        end;
      pfIsSiteMarked  : begin
                         ADOQuery3.Close;
                         ADOQuery3.SQL.Clear;
                         ADOQuery3.SQL.Add(Format(SqlStr1, ['email', 'marks', 'email', GetEmail(FromIP), 'htmurl', MyReceiveTxt]));
                         ADOQuery3.Open;
                         if ADOTable1.FieldByName('htmurl').AsString <> MyReceiveTxt then SendMsgtoC(', pfSiteYes, FromIP)
                           else SendMsgtoC(', pfSiteNot, FromIP);
                        end;
      pfIsAddMarked   : begin
                         ADOQuery3.Close;
                         ADOQuery3.SQL.Clear;
                         ADOQuery3.SQL.Add(Format(SqlStr1, ['email', 'marks', 'email', GetEmail(FromIP), 'htmurl', MyReceiveTxt]));
                         ADOQuery3.Open;
                         if ADOTable1.FieldByName('AddMarked').AsString <> 'Y' then SendMsgtoC(', pfAddNot, FromIP)
                           else SendMsgtoC(', pfAddYes, FromIP);
                        end;
      pfHtmURL        : begin
                         ADOTable1.InsertRecord([nil, DateTimeToStr(Now), GetEmail(FromIP), '0', MyReceiveTxt, ', FromIP, 'N','N','0',','0']);
                         SendMsgtoC(', pfHtmURLOK, FromIP);
                        end;
      pfHtmMarks      : begin
                         ADOQuery3.Close;
                         ADOQuery3.SQL.Clear;
                         ADOQuery3.SQL.Add(Format(SqlStr2, ['email', 'marks', 'email', GetEmail(FromIP), 'marks', '0']));
                         ADOQuery3.Open;
                         if ADOTable1.FieldByName('marks').AsString = '0' then begin
                           ADOTable1.Edit;
                           ADOTable1.FieldByName('marks').AsString := MyReceiveTxt;
                           ADOTable1.Post;
                           SendMsgtoC(', pfMarksOK, FromIP);
                         end
                         //else SendMsgtoC(', pfSthWrong, FromIP);
                        end;
      pfSiteMarks     : begin
                         tempStr := MyReceiveTxt;    //mark + site name -> (2+n)
                         Delete(tempStr, 3, length(MyReceiveTxt));  //extract the two part
                         Delete(MyReceiveTxt, 1, 2);  //site url and htm url can be stored in one field? just have a try...
                         ADOTable1.InsertRecord([nil, DateTimeToStr(Now), GetEmail(FromIP), ', MyReceiveTxt, ', FromIP, 'Y','N',tempStr,','0']);
                         SendMsgtoC(', pfMarksOK, FromIP);
                        end;
      pfAddMarks      : begin
                         tempStr := MyReceiveTxt;
                         Delete(tempStr, 3, length(MyReceiveTxt));
                         Delete(MyReceiveTxt, 1, 2);
                         ADOTable1.InsertRecord([nil, DateTimeToStr(Now), GetEmail(FromIP), ', MyReceiveTxt,', FromIP, 'N','Y',',',tempStr]);
                        end;
      pfWantHistory   : begin

                        end; 
 end;
end;
----------------------------------------------
-我是天空一片云,漂泊天涯无定所
|    __  o |__   __   __  
|_, (__( | |__) (__( (__)
作者:
男 xinhua (傻林) ★☆☆☆☆ -
盒子活跃会员
2003/12/30 7:48:17
6楼: 兄弟,这个TNMUDP控件那有呀。
----------------------------------------------
愿和所有喜欢DELPHI的人成为朋友!!
作者:
男 asklaibao (laibao) ★☆☆☆☆ -
盒子活跃会员
2003/12/30 10:21:24
7楼: TNMUDP组件在D5、D6的FashNet面板上有。也可以使用NNMSG之类的控件,都是DELPHI自带的。
----------------------------------------------
-我是天空一片云,漂泊天涯无定所
|    __  o |__   __   __  
|_, (__( | |__) (__( (__)
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行89.84375毫秒 RSS