16,748
社区成员
发帖
与我相关
我的任务
分享
procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
i: Integer;
CommData: Array of Byte;
begin
SetLength(CommData, BufferLength);
Move(Buffer, CommData, BufferLength); //接收串口数据
for I := 0 to BufferLength - 1 do // Iterate
begin
Memo1.Text:= Memo1.Text+ IntToHex(CommData[i],2)+ #32;
end; // for}
edit2.Text:= IntToStr(bufferLength);
end;
procedure TComm.CommWndProc( var msg: TMessage );
begin
case msg.msg of
PWM_GOTCOMMDATA:
begin
ReceiveData( PChar(msg.LParam), msg.WParam );
LocalFree( msg.LParam )
end;
PWM_RECEIVEERROR: ReceiveError( msg.LParam );
PWM_MODEMSTATECHANGE:ModemStateChange( msg.LParam );
PWM_REQUESTHANGUP: RequestHangup;
PWM_SENDDATAEMPTY: _SendDataEmpty
else
with msg do
begin
Result:= DefWindowProc(fHwnd, Msg, wParam, lParam);
end; // with
end
end;
else
with msg do
begin
Result:= DefWindowProc(fHwnd, Msg, wParam, lParam);
end; // with