📄 jscom1.pas
字号:
unit JsCom1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, ToolWin, ComCtrls, ImgList, StdCtrls, ExtCtrls;
type
TJsCom1 = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
end;
implementation
uses
comm1;
{ Important: Methods and properties of objects in VCL can only be used in a
method called using Synchronize, for example,
Synchronize(UpdateCaption);
and UpdateCaption could look like,
procedure TJsCom1.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }
{ TJsCom1 }
procedure TJsCom1.Execute;
var
dwEvtMask:DWORD;
Wait,SendOk:Boolean;
Read_Os:Toverlapped;
begin
{ Place thread code here }
fillchar(Read_Os,sizeof(toverlapped),0);
While True do
Begin
//waitforsingleobject(post_event,infinite);
//resetevent(post_event);
dwEvtMask:=0;
Wait:=WaitCommEvent(hcom,dwEvtMask,@Read_Os);
if Wait Then
Begin
if (dwEvtMask and Ev_Rxchar)=Ev_Rxchar then
begin
SendOk:=PostMessage(Form1.Handle,WM_COMMNOTIFY,0,0);
if not SendOk then ShowMessage('串口监视线程无法与主线程通讯!');
end;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -