C
chenxz
Unregistered / Unconfirmed
GUEST, unregistred user!
问题描述:
在Form1中调出Form2,在Form2中作了一个循环,在循环过程中,如果Form1被最小化到任务
栏,则Form2不能正常close,如果不被最小化,则可以正常close。下面是form1和form的unit,如果需要demo留个mail。
Form1上放了一个timer和一个button,form2什么都没有。
unit1:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Timer1->Enabled = true;
Form2->StartProc();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
Timer1->Enabled = false;
Form2->StopProc();
}
//---------------------------------------------------------------------------
unit2:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit2.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
bool iShow;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::StartProc()
{
//TODO: Add your source code here
int i = 0;
this->Show();
iShow = true;
while (iShow)
{
this->Caption = IntToStr(i ++);
Application->ProcessMessages();
if (i > 100)
{
i = 0;
}
Sleep(50);
}
this->Close();
}
void __fastcall TForm2::StopProc()
{
//TODO: Add your source code here
iShow = false;
}
在Form1中调出Form2,在Form2中作了一个循环,在循环过程中,如果Form1被最小化到任务
栏,则Form2不能正常close,如果不被最小化,则可以正常close。下面是form1和form的unit,如果需要demo留个mail。
Form1上放了一个timer和一个button,form2什么都没有。
unit1:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Timer1->Enabled = true;
Form2->StartProc();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
Timer1->Enabled = false;
Form2->StopProc();
}
//---------------------------------------------------------------------------
unit2:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit2.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
bool iShow;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::StartProc()
{
//TODO: Add your source code here
int i = 0;
this->Show();
iShow = true;
while (iShow)
{
this->Caption = IntToStr(i ++);
Application->ProcessMessages();
if (i > 100)
{
i = 0;
}
Sleep(50);
}
this->Close();
}
void __fastcall TForm2::StopProc()
{
//TODO: Add your source code here
iShow = false;
}