//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
bool pause=true;
//int xx=0,yy=0,rows,cols,cols1;
int rows=10,cols=10,cols1=6;
int yy=0,xx=cols/2;
//---------------------------------------------------------------------------
void delay(DWORD DT); // 延迟DT毫秒
void Inking();
//void Inking(int y,int x);
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
/*
void __fastcall TForm1::Button1Click(TObject *Sender)
{
pause=!pause;
if(pause==false)
{
Button1->Caption="暂停"; //按钮切换
for(yy=yy;yy<rows;yy++)
for(xx=xx;xx<cols/2+cols1;xx++)
Inking(yy,xx);
}
if(pause==true)
{
Button1->Caption="打点"; //按钮切换
Edit2->Text="pause!!!";
}
}
void Inking(int y,int x)
{
// total=t,ii是一个全局变量,ii=ii是为了保证暂停后可以接着暂停时候的位置继续打点
//for(ii=ii;ii<t;ii++)
if(pause==true) return;
delay(300);
Form1->Edit1->Text="xx="+IntToStr(xx)+" yy="+IntToStr(yy);
}
*/
//---------------------------------------------------------------------------
void delay(DWORD DT) // 延迟DT毫秒
{
long tt;
tt=GetTickCount();
while(GetTickCount()-tt<DT)
{
Application->ProcessMessages();
if((GetTickCount()-tt)<=0) tt=GetTickCount();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
exit(0);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
//rows=10;cols=10;cols1=6;
yy=0;xx=cols/2;
Edit2->Text="rows=10,cols=10,cols1=6,yy=0,xx=cols/2";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
pause=!pause;
if(pause==false)
{
Button1->Caption="暂停"; //按钮切换
Inking();
}
if(pause==true)
{
Button1->Caption="打点"; //按钮切换
Edit2->Text="pause!!!";
}
}
//---------------------------------------------------------------------------
void Inking()
{
// total=t,ii是一个全局变量,ii=ii是为了保证暂停后可以接着暂停时候的位置继续打点
//for(ii=ii;ii<t;ii++)
// for(yy=yy;yy<rows;yy++)
// for(xx=xx;xx<cols/2+cols1;xx++)
for(;yy<rows;yy++)
{ for(;xx<cols/2+cols1;xx++)
{
if(pause==true) return;
delay(300);
Form1->Edit3->Text="rows="+IntToStr(rows);
Form1->Edit1->Text="xx="+IntToStr(xx)+" yy="+IntToStr(yy);
}
}
}
//---------------------------------------------------------------------------