If a time demanding operation is under way and I want to enable the user to abort it by pressing a key, for example ‘Escape’, how is that possible?
For example, the code adds 8000 strings to a TListBox
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TListBox->Items->Clear();
int x=8000;
while(--x>=0) // time demanding operation here
TListBox->Items->Add(x);
}
As we all know, this kind of code “disables” the form, in this case Form1, for a few seconds depending on the system, until code has finished operation.
How can one write a similar code that doesn’t “disable” the form, and enables the user to abort it by pressing another button?
All I want is a few hints on how it ”could” be done, or if anyone has a code that actually works something like this I should be pleased if he/she would let he have a peek at it! =)
Martin G Broman
mgb_svea@thevortex.com
DWS - Alpha Whitin Dead Wolf Society
For example, the code adds 8000 strings to a TListBox
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TListBox->Items->Clear();
int x=8000;
while(--x>=0) // time demanding operation here
TListBox->Items->Add(x);
}
As we all know, this kind of code “disables” the form, in this case Form1, for a few seconds depending on the system, until code has finished operation.
How can one write a similar code that doesn’t “disable” the form, and enables the user to abort it by pressing another button?
All I want is a few hints on how it ”could” be done, or if anyone has a code that actually works something like this I should be pleased if he/she would let he have a peek at it! =)
Martin G Broman
mgb_svea@thevortex.com
DWS - Alpha Whitin Dead Wolf Society