W
wister
Unregistered / Unconfirmed
GUEST, unregistred user!
由于毕业设计,我在做语音聊天程序,其实也就是网上下载的源码改改而已。但是碰到一些问题。首先该源码用的是TUdpSock控件,我没有。于是我用TUdpSocket控件来代替,但是我不知怎么回事就是不能触发OnReceive事件。
希望大家能帮帮我,时间不多了,非常感谢。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Sockets, StdCtrls, ACMWaveOut, ACMWaveIn, ACMDialog, ScktComp,
IdUDPServer, IdBaseComponent, IdComponent, IdUDPBase, IdUDPClient;
type
TForm1 = class(TForm)
ACMDialog1: TACMDialog;
ACMWaveIn1: TACMWaveIn;
ACMWaveOut1: TACMWaveOut;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
UdpSocket1: TUdpSocket;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
procedure UdpSocket1Receive(Sender: TObject; Buf: PChar;
var DataLen: Integer);
procedure ACMWaveIn1Data(data: Pointer; size: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var formatointer;
begin
format:=ACMDialog1.OpenDialog;
udpsocket1.Active:=true;
udpsocket1.RemoteHost:=edit1.Text;
udpsocket1.Open;
udpsocket1.Connect;
if udpsocket1.Connected then application.MessageBox('connected','connected');
if format=nil then exit;
ACMWaveOut1.Open(format);
ACMWaveIn1.Open(format);
end;
procedure TForm1.ACMWaveIn1Data(data: Pointer; size: Integer);
begin
label2.Caption:=label2.Caption+' w';
udpsocket1.SendBuf(data,size);
end;
procedure TForm1.UdpSocket1Receive(Sender: TObject; Buf: PChar;
var DataLen: Integer);//无法触发,怎么办?????
begin
label1.Caption:=label1.Caption+' d';
ACMWaveOut1.PlayBack(Buf,DataLen);
end;
end.
希望大家能帮帮我,时间不多了,非常感谢。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Sockets, StdCtrls, ACMWaveOut, ACMWaveIn, ACMDialog, ScktComp,
IdUDPServer, IdBaseComponent, IdComponent, IdUDPBase, IdUDPClient;
type
TForm1 = class(TForm)
ACMDialog1: TACMDialog;
ACMWaveIn1: TACMWaveIn;
ACMWaveOut1: TACMWaveOut;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
UdpSocket1: TUdpSocket;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
procedure UdpSocket1Receive(Sender: TObject; Buf: PChar;
var DataLen: Integer);
procedure ACMWaveIn1Data(data: Pointer; size: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var formatointer;
begin
format:=ACMDialog1.OpenDialog;
udpsocket1.Active:=true;
udpsocket1.RemoteHost:=edit1.Text;
udpsocket1.Open;
udpsocket1.Connect;
if udpsocket1.Connected then application.MessageBox('connected','connected');
if format=nil then exit;
ACMWaveOut1.Open(format);
ACMWaveIn1.Open(format);
end;
procedure TForm1.ACMWaveIn1Data(data: Pointer; size: Integer);
begin
label2.Caption:=label2.Caption+' w';
udpsocket1.SendBuf(data,size);
end;
procedure TForm1.UdpSocket1Receive(Sender: TObject; Buf: PChar;
var DataLen: Integer);//无法触发,怎么办?????
begin
label1.Caption:=label1.Caption+' d';
ACMWaveOut1.PlayBack(Buf,DataLen);
end;
end.