📄 unit2.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit2.h"
#include "Unit1.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------
// Important: Methods and properties of objects in VCL can only be
// used in a method called using Synchronize, for example:
//
// Synchronize(UpdateCaption);
//
// where UpdateCaption could look like:
//
// void __fastcall TReadThread::UpdateCaption()
// {
// Form1->Caption = "Updated in a thread";
// }
//---------------------------------------------------------------------------
extern HANDLE hComm;
__fastcall TReadThread::TReadThread(bool CreateSuspended)
: TThread(CreateSuspended)
{
}
//---------------------------------------------------------------------------
void __fastcall TReadThread::Execute()
{
//---- Place thread code here ----
while(!Terminated)Synchronize(ReadData);
}
//---------------------------------------------------------------------------
void __fastcall TReadThread::ReadData()
{
//TODO: Add your source code here
String Temp;
char inbuff[1024];
DWORD nBytesRead,dwEvent,dwError;
COMSTAT cs;
if(hComm==INVALID_HANDLE_VALUE) return;
ClearCommError(hComm,&dwError,&cs);
if(cs.cbInQue>sizeof(inbuff))
{
PurgeComm(hComm,PURGE_RXCLEAR);
return;
}
ReadFile(hComm,inbuff,cs.cbInQue,&nBytesRead,NULL);
inbuff[cs.cbInQue]='\0';
Form1->Memo2->Text=Form1->Memo2->Text+inbuff;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -