进度条问题,达人入!
小弟在一个form中利用进度条表示进度。
可是为什么form中的事件无法正常响应?
向高手求教。。
cancel按钮必须点击两次才能关闭窗口,点击[关闭],进度条稍作停顿,然后继续前进。
代码我贴出来,麻烦看看怎么回事?
TCsvOutForm *CsvOutForm;
//---------------------------------------------------------------------------
__fastcall TCsvOutForm::TCsvOutForm(TComponent* Owner)
: TForm(Owner)
{
flag = false;
}
__fastcall TCsvOutForm::~TCsvOutForm(void)
{
if( stream != NULL )
{
fclose( stream );
stream = NULL;
}
if( csvstream != NULL )
{
fclose( csvstream );
csvstream = NULL;
}
if( filename != NULL)
{
delete [] filename;
filename = NULL;
}
}
//---------------------------------------------------------------------------
void __fastcall TCsvOutForm::m_btn_cancelClick(TObject *Sender)
{
flag = true;
CsvOutForm->ModalResult = mrOk;
}
//---------------------------------------------------------------------------
void __fastcall TCsvOutForm::FormActivate(TObject *Sender)
{
m_progressbar_csv->Position = 0;
convert();
CsvOutForm->ModalResult = mrOk;
}
//---------------------------------------------------------------------------
void __fastcall TCsvOutForm::onclose(TObject *Sender, TCloseAction &Action)
{
flag = true;
}
//---------------------------------------------------------------------------
void __fastcall TCsvOutForm::convert(void)
{
//进度条表示文件转换进度
for( position = 0 ; position <= max ; position ++ )
{
Application->ProcessMessages();
if(flag)
{
return;
}
Application->ProcessMessages();
.
.
workplace
.
}
}
谢谢了