//---------------------------------------------------------------------------
#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);
}
}
}
//---------------------------------------------------------------------------
用全局变量实现程序暂停/继续控制
需积分: 32 113 浏览量
2008-04-16
15:12:59
上传
评论
收藏 313KB RAR 举报
whuaidan
- 粉丝: 0
- 资源: 1
最新资源
- UE4仅k位移产生完美行走动作-UE4项目
- tensorflow-2.6.3-cp37-cp37m-manylinux2010-x86-64.whl
- tensorflow-2.6.2-cp39-cp39-win-amd64.whl
- tensorflow-2.6.2-cp39-cp39-manylinux2010-x86-64.whl
- 基于Python卷积神经网络人脸识别驾驶员疲劳检测与预警系统源码+使用说明+全部资料.zip
- BPNN-预测.rar
- 灾难分类数据集 PNG(12类 4.8K+ 张图像)
- java8和17的windows、linux版本
- MDK5.18版本,退出仿真不会有问题
- 预测-AE-1.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈