Board index » delphi » D1: Activating a button with Application.ProcessMessages

D1: Activating a button with Application.ProcessMessages

I have the following code fragement which runs a DOS program:

    result:=WinExec(RunFile, SW_SHOWMINIMIZED);
    repeat
      inc(i);
      if i>200 then begin
        {do some stuff}
      end;
      Application.ProcessMessages;
    until (GetModuleUsage(result)<1);

What I need to be able to do is interrupt this process if the user clicks
on a "cancel" button on the Windows form which remains on screen while
the DOS program runs in the background (as a minimized icon).  How???

Thanks in advance...
Derek.
--
                                                      dho...@csir.co.za
                                               No opinions. Just facts.
                                  http://www.geocities.com/Area51/6481/
                        "One warp core breach can really ruin your day."

 

Re:D1: Activating a button with Application.ProcessMessages


Quote
Derek wrote:

> I have the following code fragement which runs a DOS program:

>     result:=WinExec(RunFile, SW_SHOWMINIMIZED);
>     repeat
>       inc(i);
>       if i>200 then begin
>         {do some stuff}
>       end;
>       Application.ProcessMessages;
>     until (GetModuleUsage(result)<1);

> What I need to be able to do is interrupt this process if the user clicks
> on a "cancel" button on the Windows form which remains on screen while
> the DOS program runs in the background (as a minimized icon).  How???

Declare a variable FCancelled in your form
In the OnClick event of the button, set FCancelled true
in your 'until' line, add 'or FCancelled'
Add a line 'FCancelled := FALSE' before and after your loop

--
Need a custom component? Late on a project? Could use an util?
DOS Device driver? A VxD? NT drivers or services? Applications of any
kind?
Low rates, fast delivery!

When responding to news postings, please CC a copy to my email address.
Thanks.
Erik Sperling Johansen <e...@info-pro.no>

Other Threads