R
rovedream
Unregistered / Unconfirmed
GUEST, unregistred user!
在Dll里面动态创建的Spcomm怎样响应OnReceiveData事件<br>用 Comm1.OnReceiveData:=DoReceiveData;语句总是提示出错<br>DoReceiveData与OnReceiveData事件响应函数一样<br>procedure DoReceiveData(Sender: TObject; Buffer: Pointer;<br> BufferLength: Word);<br><br>如果将动态创建的TComm用一个类封住起来,则可以将事件处理函数赋给方法指针,但采取这种方法,我怎么发送数据,访问其他方法,属性呢,要另写方法对Comm进行操作吗?有这方面的收发数据完整例子提供吗?<br>========================= <br>type<br> TComControl = class(TObject)<br> private<br> Comm1: TComm;<br> procedure DoReceiveData(Sender: TObject; Buffer: Pointer; BufferLength: Word);<br> public<br> constructor Create(ComPort: string);<br> destructor Destroy; override;<br> end;<br><br>constructor TComControl.Create(ComPort: string);<br>begin<br> inherited Create;<br> Comm1:=TComm.Create(nil);<br> Comm1.CommName:=ComPort;<br> Comm1.OnReceiveData:=DoReceiveData;<br>end;<br><br>destructor TComControl.Destroy;<br>begin<br> if Assigned(Comm1) then Comm1.Free;<br> inherited;<br>end;<br><br>procedure TComControl.DoReceiveData(Sender: TObject; Buffer: Pointer; BufferLength: Word);<br>begin<br> //处理<br>end; <br> <br>如果这样怎样发数据呢?怎样访问原方法,属性呢