Чтение онлайн

ЖАНРЫ

Советы по Delphi. Версия 1.4.3 от 1.1.2001

Озеров Валентин

Шрифт:

 if tceCts in FEvents then inc(EventMask,EV_CTS);

 if tceCtss in FEvents then inc(EventMask,EV_CTSS);

 if tceDsr in FEvents then inc(EventMask,EV_DSR);

 if tceErr in FEvents then inc(EventMask,EV_ERR);

 if tcePErr in FEvents then inc(EventMask,EV_PERR);

 if tceRing in FEvents then inc(EventMask,EV_RING);

 if tceRlsd in FEvents then inc(EventMask,EV_RLSD);

 if tceRlsds in FEvents then inc(EventMask,EV_RLSDS);

 if tceRxChar in FEvents then inc(EventMask,EV_RXCHAR);

 if tceRxFlag in FEvents then inc(EventMask,EV_RXFLAG);

 if tceTxEmpty in FEvents then inc(EventMask,EV_TXEMPTY);

 SetCommEventMask(hComm,EventMask);

end;

procedure TComm.WndProc(var Msg:TMessage);

begin

 with Msg do begin

if Msg=WM_COMMNOTIFY then begin

case lParamLo of

CN_EVENT:

DoEvent;

CN_RECEIVE:

DoReceive;

CN_TRANSMIT:

DoTransmit;

end;

end else Result:=DefWindowProc(FWindowHandle, Msg, wParam, lParam);

 end;

end;

procedure TComm.DoEvent;

var

 CommEvent:TCommEvents;

 EventMask:Word;

begin

 if (hComm<0) or not Assigned(FOnEvent) then exit;

 EventMask:=GetCommEventMask(hComm,Integer($FFFF));

 CommEvent:=[];

 if (tceBreak in Events) and (EventMask and EV_BREAK<>0) then CommEvent:=CommEvent+[tceBreak];

 if (tceCts in Events) and (EventMask and EV_CTS<>0) then CommEvent:=CommEvent+[tceCts];

 if (tceCtss in Events) and (EventMask and EV_CTSS<>0) then CommEvent:=CommEvent+[tceCtss];

 if (tceDsr in Events) and (EventMask and EV_DSR<>0) then CommEvent:=CommEvent+[tceDsr];

 if (tceErr in Events) and (EventMask and EV_ERR<>0) then CommEvent:=CommEvent+[tceErr];

 if (tcePErr in Events) and (EventMask and EV_PERR<>0) then CommEvent:=CommEvent+[tcePErr];

 if (tceRing in Events) and (EventMask and EV_RING<>0) then CommEvent:=CommEvent+[tceRing];

 if (tceRlsd in Events) and (EventMask and EV_RLSD<>0) then CommEvent:=CommEvent+[tceRlsd];

 if (tceRlsds in Events) and (EventMask and EV_Rlsds<>0) then CommEvent:=CommEvent+[tceRlsds];

 if (tceRxChar in Events) and (EventMask and EV_RXCHAR<>0) then CommEvent:=CommEvent+[tceRxChar];

 if (tceRxFlag in Events) and (EventMask and EV_RXFLAG<>0) then CommEvent:=CommEvent+[tceRxFlag];

 if (tceTxEmpty in Events) and (EventMask and EV_TXEMPTY<>0) then CommEvent:= CommEvent+[tceTxEmpty];

 FOnEvent(Self,CommEvent);

end;

procedure TComm.DoReceive;

var Stat:TComStat;

begin

 if (hComm<0) or not Assigned(FOnReceive) then exit;

 GetCommError(hComm,Stat);

 FOnReceive(Self,Stat.cbInQue);

 GetCommError(hComm,Stat);

end;

procedure TComm.DoTransmit;

var Stat:TComStat;

begin

 if (hComm<0) or not Assigned(FOnTransmit) then exit;

 GetCommError(hComm,Stat);

 FOnTransmit(Self,Stat.cbOutQue);

end;

procedure TComm.Loaded;

begin

 inherited Loaded;

Поделиться с друзьями: