Советы по Delphi. Версия 1.4.3 от 1.1.2001
Шрифт:
var DCB:TDCB;
begin
FBaudRate:=Value;
if hComm>=0 then begin
GetCommState(hComm,DCB);
case Value of
tbr110:
DCB.BaudRate:=CBR_110;
tbr300:
DCB.BaudRate:=CBR_300;
tbr600:
DCB.BaudRate:=CBR_600;
tbr1200:
DCB.BaudRate:=CBR_1200;
tbr2400:
DCB.BaudRate:=CBR_2400;
tbr4800:
DCB.BaudRate:=CBR_4800;
tbr9600:
DCB.BaudRate:=CBR_9600;
tbr14400:
DCB.BaudRate:=CBR_14400;
tbr19200:
DCB.BaudRate:=CBR_19200;
tbr38400:
DCB.BaudRate:=CBR_38400;
tbr56000:
DCB.BaudRate:=CBR_56000;
tbr128000:
DCB.BaudRate:=CBR_128000;
tbr256000:
DCB.BaudRate:=CBR_256000;
end;
SetCommState(DCB);
end;
end;
procedure TComm.SetParity(Value:TParity);
var DCB:TDCB;
begin
FParity:=Value;
if hComm<0 then exit;
GetCommState(hComm,DCB);
case Value of
tpNone:
DCB.Parity:=0;
tpOdd:
DCB.Parity:=1;
tpEven:
DCB.Parity:=2;
tpMark:
DCB.Parity:=3;
tpSpace:
DCB.Parity:=4;
end;
SetCommState(DCB);
end;
procedure TComm.SetDataBits(Value:TDataBits);
var DCB:TDCB;
begin
FDataBits:=Value;
if hComm<0 then exit;
GetCommState(hComm,DCB);
case Value of
tdbFour:
DCB.ByteSize:=4;
tdbFive:
DCB.ByteSize:=5;
tdbSix:
DCB.ByteSize:=6;
tdbSeven:
DCB.ByteSize:=7;
tdbEight:
DCB.ByteSize:=8;
end;
SetCommState(DCB);
end;
procedure TComm.SetStopBits(Value:TStopBits);
var DCB:TDCB;
begin
FStopBits:=Value;
if hComm<0 then exit;
GetCommState(hComm,DCB);
case Value of
tsbOne:
DCB.StopBits:=0;
tsbOnePointFive:
DCB.StopBits:=1;
tsbTwo:
DCB.StopBits:=2;
end;
SetCommState(DCB);
end;
procedure TComm.SetReadBufferSize(Value:Word);
begin
FReadBufferSize:=Value;
SetPort(FPort);
end;
procedure TComm.SetWriteBufferSize(Value:Word);
begin
FWriteBufferSize:=Value;
SetPort(FPort);
end;
procedure TComm.SetRxFull(Value:Word);
begin
FRxFull:=Value;
if hComm<0 then exit;
EnableCommNotification(hComm,FWindowHandle,FRxFull,FTxLow);
end;
procedure TComm.SetTxLow(Value:Word);
begin
FTxLow:=Value;
if hComm<0 then exit;
EnableCommNotification(hComm,FWindowHandle,FRxFull,FTxLow);
end;
procedure TComm.SetEvents(Value:TCommEvents);
var EventMask:Word;
begin
FEvents:=Value;
if hComm<0 then exit;
EventMask:=0;
if tceBreak in FEvents then inc(EventMask,EV_BREAK);
Поделиться с друзьями: